diff --git a/lib/hierarchy.js b/lib/hierarchy.js index 2840b54c8..514b36835 100644 --- a/lib/hierarchy.js +++ b/lib/hierarchy.js @@ -78,9 +78,8 @@ function inferHierarchy(comments) { default: if (!comment.scope) { - parent.errors.push({ - message: 'found memberof but no @scope, @static, or @instance tag', - commentLineNumber: memberOfTagLineNumber + comment.errors.push({ + message: 'found memberof but no @scope, @static, or @instance tag' }); continue; } diff --git a/test/fixture/memberof-missing.input.js b/test/fixture/memberof-missing.input.js deleted file mode 100644 index 7ab62da45..000000000 --- a/test/fixture/memberof-missing.input.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Set the time - * @name setTime - * @param {Date} time the current time - * @memberof Foo - * @returns {undefined} nothing - */ diff --git a/test/fixture/memberof-missing.output.custom.md b/test/fixture/memberof-missing.output.custom.md deleted file mode 100644 index 14c56047c..000000000 --- a/test/fixture/memberof-missing.output.custom.md +++ /dev/null @@ -1,15 +0,0 @@ -# setTime - -Set the time - - -**Parameters** - -- `time` **Date** the current time - - - -Returns **undefined** nothing - - - diff --git a/test/fixture/memberof-missing.output.json b/test/fixture/memberof-missing.output.json deleted file mode 100644 index 3c6020750..000000000 --- a/test/fixture/memberof-missing.output.json +++ /dev/null @@ -1,96 +0,0 @@ -[ - { - "description": "Set the time", - "tags": [ - { - "title": "name", - "description": null, - "lineNumber": 2, - "name": "setTime" - }, - { - "title": "param", - "description": "the current time", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "Date" - }, - "name": "time" - }, - { - "title": "memberof", - "description": "Foo", - "lineNumber": 4 - }, - { - "title": "returns", - "description": "nothing", - "lineNumber": 5, - "type": { - "type": "UndefinedLiteral" - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 8, - "column": 0 - } - } - }, - "errors": [ - { - "message": "memberof reference to Foo not found", - "commentLineNumber": 4 - } - ], - "name": "setTime", - "params": [ - { - "title": "param", - "description": "the current time", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "Date" - }, - "name": "time" - } - ], - "memberof": "Foo", - "returns": [ - { - "title": "returns", - "description": "nothing", - "lineNumber": 5, - "type": { - "type": "UndefinedLiteral" - } - } - ], - "members": { - "instance": [], - "static": [] - }, - "events": [], - "path": [ - "setTime" - ] - } -] \ No newline at end of file diff --git a/test/fixture/memberof-missing.output.md b/test/fixture/memberof-missing.output.md deleted file mode 100644 index 14c56047c..000000000 --- a/test/fixture/memberof-missing.output.md +++ /dev/null @@ -1,15 +0,0 @@ -# setTime - -Set the time - - -**Parameters** - -- `time` **Date** the current time - - - -Returns **undefined** nothing - - - diff --git a/test/fixture/memberof-missing.output.md.json b/test/fixture/memberof-missing.output.md.json deleted file mode 100644 index 1abeac299..000000000 --- a/test/fixture/memberof-missing.output.md.json +++ /dev/null @@ -1,236 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "root", - "children": [ - { - "depth": 1, - "type": "heading", - "children": [ - { - "type": "text", - "value": "setTime" - } - ] - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Set the time", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "root", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "time" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Date" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "the current time", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - } - } - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "undefined" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "nothing", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - } - } - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/test/fixture/memberof-no-scope.input.js b/test/fixture/memberof-no-scope.input.js deleted file mode 100644 index 2c45cdf05..000000000 --- a/test/fixture/memberof-no-scope.input.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This is the class - * @class Foo - */ - -/** - * Set the time - * @name setTime - * @param {Date} time the current time - * @memberof Foo - * @returns {undefined} nothing - */ diff --git a/test/fixture/memberof-no-scope.output.custom.md b/test/fixture/memberof-no-scope.output.custom.md deleted file mode 100644 index e25b1ae6a..000000000 --- a/test/fixture/memberof-no-scope.output.custom.md +++ /dev/null @@ -1,21 +0,0 @@ -# Foo - -This is the class - - - -# setTime - -Set the time - - -**Parameters** - -- `time` **Date** the current time - - - -Returns **undefined** nothing - - - diff --git a/test/fixture/memberof-no-scope.output.json b/test/fixture/memberof-no-scope.output.json deleted file mode 100644 index 473ab978a..000000000 --- a/test/fixture/memberof-no-scope.output.json +++ /dev/null @@ -1,144 +0,0 @@ -[ - { - "description": "This is the class", - "tags": [ - { - "title": "class", - "description": null, - "lineNumber": 2, - "type": null, - "name": "Foo" - } - ], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 13, - "column": 0 - } - } - }, - "errors": [ - { - "message": "found memberof but no @scope, @static, or @instance tag", - "commentLineNumber": 4 - } - ], - "class": { - "name": "Foo" - }, - "name": "Foo", - "kind": "class", - "members": { - "instance": [], - "static": [] - }, - "events": [], - "path": [ - "Foo" - ] - }, - { - "description": "Set the time", - "tags": [ - { - "title": "name", - "description": null, - "lineNumber": 2, - "name": "setTime" - }, - { - "title": "param", - "description": "the current time", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "Date" - }, - "name": "time" - }, - { - "title": "memberof", - "description": "Foo", - "lineNumber": 4 - }, - { - "title": "returns", - "description": "nothing", - "lineNumber": 5, - "type": { - "type": "UndefinedLiteral" - } - } - ], - "loc": { - "start": { - "line": 6, - "column": 0 - }, - "end": { - "line": 12, - "column": 3 - } - }, - "context": { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 13, - "column": 0 - } - } - }, - "errors": [], - "name": "setTime", - "params": [ - { - "title": "param", - "description": "the current time", - "lineNumber": 3, - "type": { - "type": "NameExpression", - "name": "Date" - }, - "name": "time" - } - ], - "memberof": "Foo", - "returns": [ - { - "title": "returns", - "description": "nothing", - "lineNumber": 5, - "type": { - "type": "UndefinedLiteral" - } - } - ], - "members": { - "instance": [], - "static": [] - }, - "events": [], - "path": [ - "setTime" - ] - } -] \ No newline at end of file diff --git a/test/fixture/memberof-no-scope.output.md b/test/fixture/memberof-no-scope.output.md deleted file mode 100644 index e25b1ae6a..000000000 --- a/test/fixture/memberof-no-scope.output.md +++ /dev/null @@ -1,21 +0,0 @@ -# Foo - -This is the class - - - -# setTime - -Set the time - - -**Parameters** - -- `time` **Date** the current time - - - -Returns **undefined** nothing - - - diff --git a/test/fixture/memberof-no-scope.output.md.json b/test/fixture/memberof-no-scope.output.md.json deleted file mode 100644 index 6a724b900..000000000 --- a/test/fixture/memberof-no-scope.output.md.json +++ /dev/null @@ -1,297 +0,0 @@ -{ - "type": "root", - "children": [ - { - "type": "root", - "children": [ - { - "depth": 1, - "type": "heading", - "children": [ - { - "type": "text", - "value": "Foo" - } - ] - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This is the class", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 18 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 18 - } - } - } - ] - }, - { - "type": "root", - "children": [ - { - "depth": 1, - "type": "heading", - "children": [ - { - "type": "text", - "value": "setTime" - } - ] - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Set the time", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - { - "type": "root", - "children": [ - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Parameters" - } - ] - }, - { - "ordered": false, - "type": "list", - "children": [ - { - "type": "listItem", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "time" - }, - { - "type": "text", - "value": " " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "Date" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "the current time", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 17 - } - } - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Returns " - }, - { - "type": "strong", - "children": [ - { - "type": "text", - "value": "undefined" - } - ] - }, - { - "type": "text", - "value": " " - }, - { - "type": "root", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "nothing", - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 8 - } - } - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/test/lib/hierarchy.js b/test/lib/hierarchy.js index 5c9c97000..4daa40d2f 100644 --- a/test/lib/hierarchy.js +++ b/test/lib/hierarchy.js @@ -77,3 +77,23 @@ test('hierarchy - missing memberof', function (t) { }, 'correct error message'); t.end(); }); + +test('hierarchy - missing scope', function (t) { + var result = evaluate(function () { + /** + * @name Class + * @class + */ + + /** + * @name test + * @memberof Class + */ + }); + + t.equal(result.length, 2); + t.deepEqual(result[1].errors[0], { + message: 'found memberof but no @scope, @static, or @instance tag' + }, 'correct error message'); + t.end(); +});