Skip to content

Commit

Permalink
feat: add support for class param declarations at the constructor (#1013
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Shannon Poole authored and tmcw committed Feb 10, 2018
1 parent 647fdf4 commit 05c5279
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/infer/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function inferParams(comment: Comment) {

function inferAndCombineParams(params, comment) {
const inferredParams = params.map((param, i) => paramToDoc(param, '', i));
const mergedParamsAndErrors = mergeTrees(inferredParams, comment.params);
const paramsToMerge = comment.params;
if (comment.constructorComment) {
paramsToMerge.push.apply(paramsToMerge, comment.constructorComment.params);
}
const mergedParamsAndErrors = mergeTrees(inferredParams, paramsToMerge);

// Then merge the trees. This is the hard part.
return Object.assign(comment, {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function _addComment(

if (t.isClassMethod(path) && path.node.kind === 'constructor') {
// #689
if (!comment.hideconstructor) {
if (comment.tags.some(tag => tag.title !== 'param' && tag.title !== 'hideconstructor')) {
debuglog(
'A constructor was documented explicitly: document along with the class instead'
);
Expand Down

0 comments on commit 05c5279

Please sign in to comment.