Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing non-explicit @param's #499

Open
jayfreestone opened this issue Jan 31, 2018 · 4 comments
Open

Missing non-explicit @param's #499

jayfreestone opened this issue Jan 31, 2018 · 4 comments

Comments

@jayfreestone
Copy link

I'm not sure how to document functions that are created as the result of a function expression.

For instance, with Ramda's pipe function (below), the @param seems to be ignored by ESDoc. This is probably because it isn't explicit, but is required by the result of R.pipe(...).

For instance, this doesn't include the @param in the generated docs:

/**
 * Reverses and joins lngLat array for use with Mapbox.
 * @param {Array} lngLat - An array of the coordinates in the format [lng, lat].
 * @returns {String} In the format 'lat,lng'
 * @see https://www.mapbox.com/api-documentation/#static
 */
const getStaticMapImg = R.pipe(
  R.reverse,
  R.join(','),
);

This works:

/**
 * Reverses and joins lngLat array for use with Mapbox.
 * @param {Array} lngLat - An array of the coordinates in the format [lng, lat].
 * @returns {String} In the format 'lat,lng'
 * @see https://www.mapbox.com/api-documentation/#static
 */
const getStaticMapImg = lngLat => R.pipe(
  R.reverse,
  R.join(','),
)(lngLat);

But it's a bit pointless. Is there any way to force ESDoc to include an @param, even when it doesn't think it should, or any other way around this (other than putting it in the desc).

Any help is appreciated - apart from this I'm really liking ESDoc.

@TriMoon
Copy link

TriMoon commented Feb 1, 2018

Your first example is a static assignment with the value that function call returns.
The second example is static assignment with an Arrow function definition using IFF.

Neither of the two create a function called 'getStaticMapImg' which im guessing is your real intent here if the comments are taken into account...

@jayfreestone
Copy link
Author

They are assignments, but they evaluate to functions.

I don't expect ESDoc to parse dynamic assignments, but I do need a way of documenting these, since for all intents and purposes getStaticMapImg is a function to the consumer of it. You call it with a parameter and it returns a value.

All I need is for ESDoc to take my word on it and include the @params I supply in a table, as it does in the second example:

screen shot 2018-02-01 at 08 13 40

@TriMoon
Copy link

TriMoon commented Feb 1, 2018

again, the fact that your function-call produces dynamic data on call-time, does not make your const getStaticMapImg variable dynamic...
Because that expression will be processed only 1 time.

If you want it to become a function then you should declare it as such... eg:

function getStaticMapImg( ...vars... ){
...
return [your value]
}

To be 100% clear;
The way you are coding there is like creating a macro wich will become a fixed value for the consumer of it. eg. not dynamic...

@TriMoon
Copy link

TriMoon commented Feb 1, 2018

Anyway this repo is about esdoc usage and not about coding errors 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants