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
This commit is contained in:
parent
7e89af8190
commit
c686e7ea30
|
@ -30,11 +30,18 @@ module.exports = function AttachCommentTreeVisitor(ParseTreeVisitor, log) {
|
||||||
log.silly('tree: ' + tree.constructor.name + ' - ' + tree.location.start.line);
|
log.silly('tree: ' + tree.constructor.name + ' - ' + tree.location.start.line);
|
||||||
while (this.currentComment &&
|
while (this.currentComment &&
|
||||||
this.currentComment.range.end.offset < tree.location.start.offset) {
|
this.currentComment.range.end.offset < tree.location.start.offset) {
|
||||||
log.silly('comment: ' + this.currentComment.range.start.line + ' - ' +
|
var commentText = this.currentComment.range.toString();
|
||||||
this.currentComment.range.end.line + ' : ' +
|
|
||||||
this.currentComment.range.toString());
|
// Only store the comment if it is JSDOC style (e.g. /** some comment */)
|
||||||
tree.commentBefore = this.currentComment;
|
if (/^\/\*\*([\w\W]*)\*\/$/.test(commentText)) {
|
||||||
this.currentComment.treeAfter = tree;
|
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.index++;
|
||||||
this.currentComment = this.comments[this.index];
|
this.currentComment = this.comments[this.index];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue