Skip to content

Is it possible to rename $0 when documenting destructured params? #677

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

Closed
aaronjensen opened this issue Feb 24, 2017 · 2 comments · Fixed by #732
Closed

Is it possible to rename $0 when documenting destructured params? #677

aaronjensen opened this issue Feb 24, 2017 · 2 comments · Fixed by #732

Comments

@aaronjensen
Copy link

It's possible to name the parts of $0, which is great, but it'd be nice if I could name $0 itself. Is this possible?

@tmcw
Copy link
Member

tmcw commented Feb 24, 2017

Sorry, currently that's not possible. The relevant code is

path.node.params
.reduce(function (params, param, i) {
return params.concat(paramToDoc(param, comment, i, ''));
}, [])
.forEach(function (doc) {
if (!existingParams.hasOwnProperty(doc.name)) {
// This type is not explicitly documented
comment.params = insertBeforeDependents(doc, comment.params);
} else if (!existingParams[doc.name].type) {
// This param has a description, but potentially it can
// be have an inferred type. Infer its type without
// dropping the description.
if (doc.type) {
existingParams[doc.name].type = doc.type;
}
} else if (existingParams[doc.name].type.type !== 'OptionalType' &&
doc.default) {
existingParams[doc.name].type = {
type: 'OptionalType',
expression: existingParams[doc.name].type,
default: doc.default
};
}
paramOrder[doc.name] = i++;
});

We're handling:

  • Inferring names of parameters
  • Combining inferred types with parameters also declared with @param for named arguments
  • Inferring default values for optional parameters

But we don't yet support naming destructuring params, but I'd be overjoyed to review a PR implementing such support. Most likely it'd, instead of indexing params by name and matching them that way, as we do currently, would assume that if someone uses @param explicit tags, they're going to provide them in the correct order and we should match them one by one with inferred information.

@tmcw
Copy link
Member

tmcw commented Apr 15, 2017

This will be fixed in #732 - in fact, it'll be required that to refer to inferred destructuring arguments, you need to name them.

@tmcw tmcw closed this as completed in #732 Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants