Skip to content

Commit dfea5d0

Browse files
committed
extract comments from inherticDoc
1 parent 53ec474 commit dfea5d0

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

src/services/jsDoc.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ namespace ts.JsDoc {
9393
const parts: SymbolDisplayPart[][] = [];
9494
forEachUnique(declarations, declaration => {
9595
for (const jsdoc of getCommentHavingNodes(declaration)) {
96+
const inheritDoc = isJSDoc(jsdoc) && jsdoc.tags && find(jsdoc.tags, t => t.kind === SyntaxKind.JSDocTag && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"));
9697
// skip comments containing @typedefs since they're not associated with particular declarations
9798
// Exceptions:
9899
// - @typedefs are themselves declarations with associated comments
99100
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
100-
if (jsdoc.comment === undefined
101+
if (jsdoc.comment === undefined && !inheritDoc
101102
|| isJSDoc(jsdoc)
102103
&& declaration.kind !== SyntaxKind.JSDocTypedefTag && declaration.kind !== SyntaxKind.JSDocCallbackTag
103104
&& jsdoc.tags
104105
&& jsdoc.tags.some(t => t.kind === SyntaxKind.JSDocTypedefTag || t.kind === SyntaxKind.JSDocCallbackTag)
105106
&& !jsdoc.tags.some(t => t.kind === SyntaxKind.JSDocParameterTag || t.kind === SyntaxKind.JSDocReturnTag)) {
106107
continue;
107108
}
108-
const newparts = getDisplayPartsFromComment(jsdoc.comment, checker);
109+
let newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : [];
110+
if (inheritDoc && inheritDoc.comment) {
111+
newparts = newparts.concat(getDisplayPartsFromComment(inheritDoc.comment, checker));
112+
}
109113
if (!contains(parts, newparts, isIdenticalListOfDisplayParts)) {
110114
parts.push(newparts);
111115
}

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ namespace ts {
592592
* @returns `true` if `node` has a JSDoc "inheritDoc" tag on it, otherwise `false`.
593593
*/
594594
function hasJSDocInheritDocTag(node: Node) {
595-
return getJSDocTags(node).some(tag => tag.tagName.text === "inheritDoc");
595+
return getJSDocTags(node).some(tag => tag.tagName.text === "inheritDoc" || tag.tagName.text === "inheritdoc");
596596
}
597597

598598
function getJsDocTagsOfDeclarations(declarations: Declaration[] | undefined, checker: TypeChecker | undefined): JSDocTagInfo[] {

tests/baselines/reference/quickInfoInheritDoc.baseline

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@
396396
{
397397
"text": "text over tag",
398398
"kind": "text"
399+
},
400+
{
401+
"text": "text after tag",
402+
"kind": "text"
399403
}
400404
],
401405
"tags": [

tests/baselines/reference/quickInfoInheritDoc2.baseline

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
{
7171
"text": "Base.prop",
7272
"kind": "text"
73+
},
74+
{
75+
"text": "\n",
76+
"kind": "lineBreak"
77+
},
78+
{
79+
"text": "SubClass.prop",
80+
"kind": "text"
7381
}
7482
],
7583
"tags": [

tests/baselines/reference/quickInfoInheritDoc3.baseline

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@
5858
{
5959
"text": "Base.prop",
6060
"kind": "text"
61+
},
62+
{
63+
"text": "\n",
64+
"kind": "lineBreak"
65+
},
66+
{
67+
"text": "SubClass.prop",
68+
"kind": "text"
6169
}
6270
],
6371
"tags": [

0 commit comments

Comments
 (0)