mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Fix for case where a @lends tag was on an object literal, and an anonymous @constructs tag was on a property would throw an error.
This commit is contained in:
parent
75883bb99f
commit
df45f945b4
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "JSDoc",
|
||||
"version": "3.0.0alpha",
|
||||
"revision": "1317589569882",
|
||||
"revision": "1317933183738",
|
||||
"description": "An automatic documentation generator for javascript.",
|
||||
"keywords": [ "documentation", "javascript" ],
|
||||
"licenses": [
|
||||
|
||||
@ -96,7 +96,7 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
||||
currentSourceName = sourceName;
|
||||
|
||||
sourceCode = pretreat(sourceCode);
|
||||
|
||||
|
||||
var ast = parserFactory().parse(sourceCode, sourceName, 1);
|
||||
|
||||
var e = {filename: currentSourceName};
|
||||
@ -159,7 +159,7 @@ exports.Parser.prototype.astnodeToMemberof = function(node) {
|
||||
exports.Parser.prototype.resolveThis = function(node) {
|
||||
var memberof = {};
|
||||
|
||||
if (node.enclosingFunction) {
|
||||
if (node.type !== Token.COLON && node.enclosingFunction) {
|
||||
memberof.id = 'astnode'+node.enclosingFunction.hashCode();
|
||||
memberof.doclet = this.refs[memberof.id];
|
||||
|
||||
@ -190,8 +190,7 @@ exports.Parser.prototype.resolveThis = function(node) {
|
||||
if (parent.type === Token.COLON) parent = parent.parent; // go up one more
|
||||
|
||||
memberof.id = 'astnode'+parent.hashCode();
|
||||
memberof.doclet = this.refs[memberof.id];
|
||||
|
||||
memberof.doclet = this.refs[memberof.id];
|
||||
if (!memberof.doclet) return ''; // global?
|
||||
|
||||
return memberof.doclet.longname||memberof.doclet.name;
|
||||
|
||||
14
test/cases/constructstag5.js
Normal file
14
test/cases/constructstag5.js
Normal file
@ -0,0 +1,14 @@
|
||||
Duck = (function() {
|
||||
return /** @lends Duck# */ {
|
||||
/**
|
||||
Constructs a duck.
|
||||
@constructs
|
||||
@param tog
|
||||
*/
|
||||
constructor: function(tog) {
|
||||
},
|
||||
/** Say hello. */
|
||||
quack: function() {
|
||||
}
|
||||
}
|
||||
})();
|
||||
@ -118,6 +118,7 @@ testFile('test/t/cases/constructstag.js');
|
||||
testFile('test/t/cases/constructstag2.js');
|
||||
testFile('test/t/cases/constructstag3.js');
|
||||
testFile('test/t/cases/constructstag4.js');
|
||||
testFile('test/t/cases/constructstag5.js');
|
||||
testFile('test/t/cases/constructortag.js');
|
||||
testFile('test/t/cases/copyrighttag.js');
|
||||
testFile('test/t/cases/defaulttag.js');
|
||||
|
||||
13
test/t/cases/constructstag5.js
Normal file
13
test/t/cases/constructstag5.js
Normal file
@ -0,0 +1,13 @@
|
||||
(function() {
|
||||
var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag5.js'),
|
||||
duck = docSet.getByLongname('Duck').filter(function($) {
|
||||
return ! $.undocumented;
|
||||
})[0];
|
||||
|
||||
test('When a object literal property has an @constructs tag with no value, and the object has a @lends, the property is documented as the lent class.', function() {
|
||||
assert.equal(duck.longname, 'Duck');
|
||||
assert.equal(duck.kind, 'class');
|
||||
assert.equal(duck.description, 'Constructs a duck.');
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user