From fe3045ee6b73117733740c001b555f3d1417d5c9 Mon Sep 17 00:00:00 2001 From: Leo Nicolle Date: Fri, 20 Jan 2023 11:43:50 +0100 Subject: [PATCH 1/2] add comments for referenced parameters in function signatures, see #2147 --- src/lib/converter/plugins/CommentPlugin.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/converter/plugins/CommentPlugin.ts b/src/lib/converter/plugins/CommentPlugin.ts index 899611e1a..11bc53bc5 100644 --- a/src/lib/converter/plugins/CommentPlugin.ts +++ b/src/lib/converter/plugins/CommentPlugin.ts @@ -386,9 +386,10 @@ export class CommentPlugin extends ConverterComponent { ); if (tag) { - parameter.comment = new Comment( - Comment.cloneDisplayParts(tag.content) - ); + if(!parameter.comment){ + parameter.comment = new Comment(); + } + parameter.comment.summary = Comment.cloneDisplayParts(tag.content); } }); @@ -542,6 +543,18 @@ function moveNestedParamTags(comment: Comment, parameter: ParameterReflection) { } } }, + reference(){ + comment.blockTags.filter( + (t) => + t.tag === "@param" && + t.name?.startsWith(`${parameter.name}.`) + ).forEach(tag => { + if(!parameter.comment){ + parameter.comment = new Comment(); + } + parameter.comment.blockTags.push(tag); + }) + }, // #1876, also do this for unions/intersections. union(u) { u.types.forEach((t) => t.visit(visitor)); From cb487811070141d87fe4dc42f611c50ee0456179 Mon Sep 17 00:00:00 2001 From: Leo Nicolle Date: Fri, 20 Jan 2023 14:16:14 +0100 Subject: [PATCH 2/2] lint --- src/lib/converter/plugins/CommentPlugin.ts | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/lib/converter/plugins/CommentPlugin.ts b/src/lib/converter/plugins/CommentPlugin.ts index 11bc53bc5..ae3a30017 100644 --- a/src/lib/converter/plugins/CommentPlugin.ts +++ b/src/lib/converter/plugins/CommentPlugin.ts @@ -386,10 +386,12 @@ export class CommentPlugin extends ConverterComponent { ); if (tag) { - if(!parameter.comment){ + if (!parameter.comment) { parameter.comment = new Comment(); } - parameter.comment.summary = Comment.cloneDisplayParts(tag.content); + parameter.comment.summary = Comment.cloneDisplayParts( + tag.content + ); } }); @@ -543,17 +545,19 @@ function moveNestedParamTags(comment: Comment, parameter: ParameterReflection) { } } }, - reference(){ - comment.blockTags.filter( - (t) => - t.tag === "@param" && - t.name?.startsWith(`${parameter.name}.`) - ).forEach(tag => { - if(!parameter.comment){ - parameter.comment = new Comment(); - } - parameter.comment.blockTags.push(tag); - }) + reference() { + comment.blockTags + .filter( + (t) => + t.tag === "@param" && + t.name?.startsWith(`${parameter.name}.`) + ) + .forEach((tag) => { + if (!parameter.comment) { + parameter.comment = new Comment(); + } + parameter.comment.blockTags.push(tag); + }); }, // #1876, also do this for unions/intersections. union(u) {