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

@option tag #115

Closed
gberger opened this issue Feb 28, 2014 · 1 comment
Closed

@option tag #115

gberger opened this issue Feb 28, 2014 · 1 comment

Comments

@gberger
Copy link

gberger commented Feb 28, 2014

In JS, the options parameter is a common pattern used to encapsulate many named optional parameters into one object.

It is very important to document what these possible options are, including their name, type, default value and explanation.

Currently, dox has not support for this, apart from using a homebaked list in the method's. An official example shows how this is done:

/**
 * Output the given `str` to _stdout_
 * or the stream specified by `options`.
 * 
 * Options:
 * 
 *   - `stream` defaulting to _stdout_
 * 
 * Examples:
 * 
 *     mymodule.write('foo')
 *     mymodule.write('foo', { stream: process.stderr })
 * 
 */

exports.write = function(str, options) {
  options = options || {};
  (options.stream || process.stdout).write(str);
};

It would be very handy to have an @options tag to document more systematically this important aspect of many functions.

@gberger gberger mentioned this issue Mar 6, 2014
@evindor
Copy link
Collaborator

evindor commented Jul 7, 2014

I'm not really sure we should add support for non-standard tags. On the other hand, we already have @api. The problem with @option is that it's not as simple as boolean @api.

I may suggest you to use the following comment style:

/**
 * @param {Object} options
 * @param {string} options.name User's name
 * @param {number} options.age User's age
 */

P.S. Please continue discussion if you feel that we should do it. I see how useful this tag might be. Just want to hear some arguments — it would be great if you could find @option uses in popular projects — i couldn't.

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

Successfully merging a pull request may close this issue.

2 participants