|
|
@ -163,7 +163,7 @@ class ParseWalker { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/* |
|
|
|
Find the nearest comment to this line, giving |
|
|
|
Find the nearest comment to this line, giving |
|
|
|
about 2 lines of slack. |
|
|
|
about 2 lines of slack. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -179,6 +179,21 @@ class ParseWalker { |
|
|
|
return undefined; |
|
|
|
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) { |
|
|
|
handle_export(_node) { |
|
|
|
switch(_node.declaration.type) { |
|
|
|
switch(_node.declaration.type) { |
|
|
|
case "ClassDeclaration": |
|
|
|
case "ClassDeclaration": |
|
|
@ -227,9 +242,13 @@ const parse_source = (source) => { |
|
|
|
ExportNamedDeclaration: (_node) => walker.handle_export(_node), |
|
|
|
ExportNamedDeclaration: (_node) => walker.handle_export(_node), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let comment = walker.file_comment(); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
// normalize to / even on windows
|
|
|
|
// normalize to / even on windows
|
|
|
|
source: source.replaceAll("\\", "/"), |
|
|
|
source: source.replaceAll("\\", "/"), |
|
|
|
|
|
|
|
// find the first comment for the file's comment
|
|
|
|
|
|
|
|
comment, |
|
|
|
exports: walker.exported, |
|
|
|
exports: walker.exported, |
|
|
|
orphan_comments: walker.comments.filter(c => !c.found) |
|
|
|
orphan_comments: walker.comments.filter(c => !c.found) |
|
|
|
}; |
|
|
|
}; |
|
|
|