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.

This commit is contained in:
Michael Mathews 2011-09-13 10:07:47 +01:00
parent bf21286685
commit 0341d71d4b
4 changed files with 16 additions and 4 deletions

View File

@ -47,9 +47,14 @@
} }
if (newDoclet.alias) { if (newDoclet.alias) {
if (newDoclet.alias === '{@this}') { if (newDoclet.alias === '{@thisClass}') {
memberofName = this.resolveThis(e.astnode); 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.addTag('name', newDoclet.alias);
newDoclet.postProcess(); newDoclet.postProcess();

View File

@ -113,7 +113,7 @@
onTagged: function(doclet, tag) { onTagged: function(doclet, tag) {
var ownerClassName; var ownerClassName;
if (!tag.value) { if (!tag.value) {
ownerClassName = '{@this}'; // this can be resolved later in the handlers ownerClassName = '{@thisClass}'; // this can be resolved later in the handlers
} }
else { else {
ownerClassName = firstWordOf(tag.value); ownerClassName = firstWordOf(tag.value);

View File

@ -1,4 +1,4 @@
var Person = Class.create(/** @lends Person */{ var Person = Class.create(/** @lends Person# */{
/** /**
Describe the constructor. Describe the constructor.

View File

@ -1,7 +1,14 @@
(function() { (function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag4.js'), var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag4.js'),
person = docSet.getByLongname('Person').filter(function($) {
return ! $.undocumented;
})[0],
personName = docSet.getByLongname('Person#name')[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() { 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.memberof, 'Person');
assert.equal(personName.scope, 'instance'); assert.equal(personName.scope, 'instance');