From c686e7ea30e876b4dff0054380af2834882679e5 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 24 Mar 2015 11:25:58 +0000 Subject: [PATCH] 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 #1072 --- .../services/AttachCommentTreeVisitor.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/dgeni-package/services/AttachCommentTreeVisitor.js b/docs/dgeni-package/services/AttachCommentTreeVisitor.js index d63b6a1144..6aa7b3b907 100644 --- a/docs/dgeni-package/services/AttachCommentTreeVisitor.js +++ b/docs/dgeni-package/services/AttachCommentTreeVisitor.js @@ -30,11 +30,18 @@ module.exports = function AttachCommentTreeVisitor(ParseTreeVisitor, log) { log.silly('tree: ' + tree.constructor.name + ' - ' + tree.location.start.line); while (this.currentComment && this.currentComment.range.end.offset < tree.location.start.offset) { - log.silly('comment: ' + this.currentComment.range.start.line + ' - ' + - this.currentComment.range.end.line + ' : ' + - this.currentComment.range.toString()); - tree.commentBefore = this.currentComment; - this.currentComment.treeAfter = tree; + var commentText = this.currentComment.range.toString(); + + // Only store the comment if it is JSDOC style (e.g. /** some comment */) + if (/^\/\*\*([\w\W]*)\*\/$/.test(commentText)) { + log.info('comment: ' + this.currentComment.range.start.line + ' - ' + + this.currentComment.range.end.line + ' : ' + + commentText); + + tree.commentBefore = this.currentComment; + this.currentComment.treeAfter = tree; + } + this.index++; this.currentComment = this.comments[this.index]; }