Skip to content

Commit 0025d53

Browse files
committed
fix(parser): handle single line comments
1 parent 3502d40 commit 0025d53

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: src/parser.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,14 @@ export function parseFromProgram(
435435
if (comments && comments.length === 1) {
436436
const commentNode = comments[0];
437437
if (ts.isJSDoc(commentNode)) {
438-
return (
439-
commentNode
440-
// Full comment text
441-
.getText()
442-
// Remove markers (/**\n* */)
443-
.replace(/(^\/\*\*.*$)|(^ *\*\/)|(^ *\* ?)/gm, '')
444-
.trim()
445-
);
438+
let commentText = commentNode.comment ? commentNode.comment : '';
439+
if (commentNode.tags) {
440+
const tags = commentNode.tags
441+
.map(tag => tag.getText().trim())
442+
.reduce((prev, curr) => `${prev}\n${curr}`);
443+
commentText = commentText ? `${commentText}\n${tags}` : tags;
444+
}
445+
return commentText;
446446
}
447447
}
448448
}

0 commit comments

Comments
 (0)