Skip to content

Commit c686e7e

Browse files
chore(doc-gen): ignore non-jsdoc style comments
Now the visitor will find the last jsdoc style comment (e.g. `/** jsdoc comment */`) before the current code item, ignoring any inline style comments (e.g. `// inline comment`) in between. Closes angular#1072
1 parent 7e89af8 commit c686e7e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

docs/dgeni-package/services/AttachCommentTreeVisitor.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@ module.exports = function AttachCommentTreeVisitor(ParseTreeVisitor, log) {
3030
log.silly('tree: ' + tree.constructor.name + ' - ' + tree.location.start.line);
3131
while (this.currentComment &&
3232
this.currentComment.range.end.offset < tree.location.start.offset) {
33-
log.silly('comment: ' + this.currentComment.range.start.line + ' - ' +
34-
this.currentComment.range.end.line + ' : ' +
35-
this.currentComment.range.toString());
36-
tree.commentBefore = this.currentComment;
37-
this.currentComment.treeAfter = tree;
33+
var commentText = this.currentComment.range.toString();
34+
35+
// Only store the comment if it is JSDOC style (e.g. /** some comment */)
36+
if (/^\/\*\*([\w\W]*)\*\/$/.test(commentText)) {
37+
log.info('comment: ' + this.currentComment.range.start.line + ' - ' +
38+
this.currentComment.range.end.line + ' : ' +
39+
commentText);
40+
41+
tree.commentBefore = this.currentComment;
42+
this.currentComment.treeAfter = tree;
43+
}
44+
3845
this.index++;
3946
this.currentComment = this.comments[this.index];
4047
}

0 commit comments

Comments
 (0)