Skip to content

Commit ad4dddd

Browse files
committedJul 22, 2019
fix(parser): handle comments with tags
1 parent eadaf3f commit ad4dddd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎src/parser.ts

+19
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,25 @@ export function parseFromProgram(
385385
return undefined;
386386
}
387387

388+
const decl = symbol.getDeclarations();
389+
if (decl) {
390+
// @ts-ignore - Private method
391+
const comments = ts.getJSDocCommentsAndTags(decl[0]) as any[];
392+
if (comments && comments.length === 1) {
393+
const commentNode = comments[0];
394+
if (ts.isJSDoc(commentNode) && commentNode.comment && commentNode.tags) {
395+
return (
396+
commentNode
397+
// Full comment text
398+
.getText()
399+
// Remove markers (/**\n* */)
400+
.replace(/(^\/\*\*.*$)|(^ *\*\/)|(^ *\* ?)/gm, '')
401+
.trim()
402+
);
403+
}
404+
}
405+
}
406+
388407
const comment = ts.displayPartsToString(symbol.getDocumentationComment(checker));
389408
return comment ? comment : undefined;
390409
}

0 commit comments

Comments
 (0)
Please sign in to comment.