From 0341d71d4beaa9b6466390d4b3326efcd74791fd Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Tue, 13 Sep 2011 10:07:47 +0100 Subject: [PATCH] When a function symbol has an @constructs tag with no value, in a @lends block with a "Name#" value, the function is documented as a constructor of "Name". Closes #31. --- rhino_modules/jsdoc/src/handlers.js | 9 +++++++-- rhino_modules/jsdoc/tag/dictionary/definitions.js | 2 +- test/cases/constructstag4.js | 2 +- test/t/cases/constructstag4.js | 7 +++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/rhino_modules/jsdoc/src/handlers.js b/rhino_modules/jsdoc/src/handlers.js index 95640ccd..348906fa 100644 --- a/rhino_modules/jsdoc/src/handlers.js +++ b/rhino_modules/jsdoc/src/handlers.js @@ -47,9 +47,14 @@ } if (newDoclet.alias) { - if (newDoclet.alias === '{@this}') { + if (newDoclet.alias === '{@thisClass}') { memberofName = this.resolveThis(e.astnode); - newDoclet.alias = memberofName;//'Blizp' + + // "class" refers to the owner of the prototype, not the prototype itself + if ( /^(.+?)(\.prototype|#)$/.test(memberofName) ) { + memberofName = RegExp.$1; + } + newDoclet.alias = memberofName; } newDoclet.addTag('name', newDoclet.alias); newDoclet.postProcess(); diff --git a/rhino_modules/jsdoc/tag/dictionary/definitions.js b/rhino_modules/jsdoc/tag/dictionary/definitions.js index a74535bb..d62d8d7b 100644 --- a/rhino_modules/jsdoc/tag/dictionary/definitions.js +++ b/rhino_modules/jsdoc/tag/dictionary/definitions.js @@ -113,7 +113,7 @@ onTagged: function(doclet, tag) { var ownerClassName; if (!tag.value) { - ownerClassName = '{@this}'; // this can be resolved later in the handlers + ownerClassName = '{@thisClass}'; // this can be resolved later in the handlers } else { ownerClassName = firstWordOf(tag.value); diff --git a/test/cases/constructstag4.js b/test/cases/constructstag4.js index 59395b58..f00cbf35 100644 --- a/test/cases/constructstag4.js +++ b/test/cases/constructstag4.js @@ -1,4 +1,4 @@ -var Person = Class.create(/** @lends Person */{ +var Person = Class.create(/** @lends Person# */{ /** Describe the constructor. diff --git a/test/t/cases/constructstag4.js b/test/t/cases/constructstag4.js index d8eabe49..bf4ea5db 100644 --- a/test/t/cases/constructstag4.js +++ b/test/t/cases/constructstag4.js @@ -1,7 +1,14 @@ (function() { var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag4.js'), + person = docSet.getByLongname('Person').filter(function($) { + return ! $.undocumented; + })[0], personName = docSet.getByLongname('Person#name')[0]; + test('When a function symbol has an @constructs tag with no value, in a @lends block with a "Name#" value, the function is documented as a constructor of "Name".', function() { + assert.equal(person.kind, 'class'); + }); + test('When a function symbol has an @constructs tag with no value, any this-variables are ducumented as instance members of the class.', function() { assert.equal(personName.memberof, 'Person'); assert.equal(personName.scope, 'instance');