|
|
|
@ -163,7 +163,7 @@ class ParseWalker { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
/* |
|
|
|
|
Find the nearest comment to this line, giving |
|
|
|
|
about 2 lines of slack. |
|
|
|
|
*/ |
|
|
|
@ -179,6 +179,21 @@ class ParseWalker { |
|
|
|
|
return undefined; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
Returns the first comment as the file's main doc comment, or undefined if there isn't one. |
|
|
|
|
*/ |
|
|
|
|
file_comment() { |
|
|
|
|
const comment = this.comments[0]; |
|
|
|
|
|
|
|
|
|
if(comment && comment.start === 1) { |
|
|
|
|
// kind of a hack, but find_comment will find this now
|
|
|
|
|
return this.find_comment(comment.end + 1); |
|
|
|
|
} else { |
|
|
|
|
return undefined; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handle_export(_node) { |
|
|
|
|
switch(_node.declaration.type) { |
|
|
|
|
case "ClassDeclaration": |
|
|
|
@ -227,9 +242,13 @@ const parse_source = (source) => { |
|
|
|
|
ExportNamedDeclaration: (_node) => walker.handle_export(_node), |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let comment = walker.file_comment(); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
// normalize to / even on windows
|
|
|
|
|
source: source.replaceAll("\\", "/"), |
|
|
|
|
// find the first comment for the file's comment
|
|
|
|
|
comment, |
|
|
|
|
exports: walker.exported, |
|
|
|
|
orphan_comments: walker.comments.filter(c => !c.found) |
|
|
|
|
}; |
|
|
|
|