Parse top-level floating comments

This commit is contained in:
John Firebaugh 2015-03-13 14:55:38 -07:00
parent c1d8695471
commit 09ef9865cf
2 changed files with 33 additions and 2 deletions

View File

@ -146,13 +146,17 @@ module.exports = function (indexes) {
file: data.file
};
if (path.parent.node) {
if (path.parent && path.parent.node) {
comment.context.code = code.substring
.apply(code, path.parent.node.range);
}
}
types.visit(ast, {
visitProgram: makeVisitor(function (comment, node, path) {
addContext(comment, path);
}),
visitMemberExpression: makeVisitor(function (comment, node, path) {
inferName(comment, node.property.name);
addContext(comment, path);

View File

@ -1 +1,28 @@
[]
[
{
"description": "This function returns the number one.",
"tags": [
{
"title": "return",
"description": "numberone",
"type": {
"type": "NameExpression",
"name": "Number"
}
}
],
"context": {
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 0
}
},
"file": "fixture/comment-only.input.js"
}
}
]