diff --git a/modules/jsdoc/name.js b/modules/jsdoc/name.js index 46869867..3765a878 100644 --- a/modules/jsdoc/name.js +++ b/modules/jsdoc/name.js @@ -28,11 +28,6 @@ memberof = doclet.memberof || '', about = {}, parentDoc; - -// TODO -// if (currentModule) { -// name = name.replace(/^exports\.(?=.+$)/, currentModule + '.'); -// } name = name? (''+name).replace(/\.prototype\.?/g, '#') : ''; @@ -62,7 +57,7 @@ doclet.memberof = about.memberof; } - if (about.longname) { + if (about.longname && !doclet.longname) { doclet.longname = about.longname; } @@ -74,13 +69,11 @@ doclet.scope = puncToScope[about.scope]; } else { - if (doclet.name && doclet.memberof) { + if (doclet.name && doclet.memberof && !doclet.longname) { doclet.scope = 'static'; // default scope when none is provided doclet.longname = doclet.memberof + scopeToPunc[doclet.scope] + doclet.name; } } - - } function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters which need to be quoted by us diff --git a/modules/jsdoc/src/parser.js b/modules/jsdoc/src/parser.js index 32f538bc..6300b4e5 100644 --- a/modules/jsdoc/src/parser.js +++ b/modules/jsdoc/src/parser.js @@ -153,6 +153,10 @@ if (memberof.doclet['this']) { return memberof.doclet['this']; } + // like: Foo.constructor = function(n) { /** blah */ this.name = n; } + else if (memberof.doclet.kind === 'function' && memberof.doclet.memberof) { + return memberof.doclet.memberof; + } // walk up to the closest class we can find else if (memberof.doclet.kind === 'class' || memberof.doclet.kind === 'module') { return memberof.doclet.longname||memberof.doclet.name; diff --git a/modules/jsdoc/tag/dictionary/definitions.js b/modules/jsdoc/tag/dictionary/definitions.js index e82dc8f5..581418d9 100644 --- a/modules/jsdoc/tag/dictionary/definitions.js +++ b/modules/jsdoc/tag/dictionary/definitions.js @@ -53,7 +53,7 @@ // handle special case where both @class and @constructor tags exist in same doclet if (tag.originalTitle === 'class') { if ( /@construct(s|or)\b/i.test(doclet.comment) ) { - doclet.classdesc = tag.value; // treat @class tag as a @classdesc tag instead + doclet.classdesc = tag.value; // treat the @class tag as a @classdesc tag instead return; } } @@ -193,9 +193,7 @@ dictionary.defineTag('instance', { onTagged: function(doclet, tag) { - setDocletScopeToTitle(doclet, tag); - - + setDocletScopeToTitle(doclet, tag); } }); @@ -203,6 +201,13 @@ mustHaveValue: true }); + dictionary.defineTag('license', { + mustHaveValue: true, + onTagged: function(doclet, tag) { + doclet.license = tag.value; + } + }); + dictionary.defineTag('alias', { mustHaveValue: true, onTagged: function(doclet, tag) { @@ -274,6 +279,15 @@ } }); + dictionary.defineTag('project', { + mustHaveValue: true, + onTagged: function(doclet, tag) { + setDocletKindToTitle(doclet, tag); + setDocletNameToValue(doclet, tag); + applyNamespace(doclet, tag); + } + }); + dictionary.defineTag('property', { onTagged: function(doclet, tag) { setDocletKindToTitle(doclet, tag); @@ -413,7 +427,8 @@ function applyNamespace(doclet, tag) { if (!doclet.name) return; // error? - doclet.name = app.jsdoc.name.applyNamespace(doclet.name, tag.title) + //doclet.displayname = doclet.name; + doclet.longname = app.jsdoc.name.applyNamespace(doclet.name, tag.title) } function setDocletNameToFilename(doclet, tag) { diff --git a/templates/default/publish.js b/templates/default/publish.js index f4b3a209..3e0fcde4 100644 --- a/templates/default/publish.js +++ b/templates/default/publish.js @@ -85,17 +85,16 @@ var modules = data.get( data.find({kind: 'module'}) ); modules.forEach(function(m) { m.methods = data.get( data.find({kind: 'function', memberof: m.longname}) ); - m.displayName = m.longname.replace(/^module:/, ''); m.hasMethods = (m.methods && m.methods.length > 0); - m.methods.forEach(function(f) { + m.methods.forEach(function(f) { var pnames = []; if (f.params) { f.params.forEach(function(p) { if (p.name && p.name.indexOf('.') === -1) { pnames.push(p.name); } }); } - f.synopsis = 'require("'+m.displayName+'").'+f.name+'('+pnames.join(', ')+');' + f.synopsis = 'require("'+m.name+'").'+f.name+'('+pnames.join(', ')+');' f.hasParams = (f.params && f.params.length > 0); f.hasReturns = (f.returns && f.returns.length > 0); }); diff --git a/templates/default/tmpl/container.mustache b/templates/default/tmpl/container.mustache index 7dfe1b3b..a2eae66a 100644 --- a/templates/default/tmpl/container.mustache +++ b/templates/default/tmpl/container.mustache @@ -168,7 +168,7 @@

{{title}}

{{#docs}} -

{{displayName}}

+

{{name}}

{{#hasMethods}}

Methods

diff --git a/test/cases/constructstag.js b/test/cases/constructstag.js index f702aa21..3e19a8ae 100644 --- a/test/cases/constructstag.js +++ b/test/cases/constructstag.js @@ -2,7 +2,7 @@ Describe your class here @class TextBlock */ -classify('TextBlock', { +Classify('TextBlock', { /** Document your constructor function here. @@ -17,6 +17,6 @@ classify('TextBlock', { Document your method here. @memberof TextBlock# */ - align: function(){ + align: function() { } }); \ No newline at end of file diff --git a/test/cases/constructstag3.js b/test/cases/constructstag3.js new file mode 100644 index 00000000..3b4e410f --- /dev/null +++ b/test/cases/constructstag3.js @@ -0,0 +1,26 @@ +/** + A class that represents a person. + @class + */ +var Person = Class.create({ + + /** + @constructs Person + @param {string} name + */ + initialize: function(name) { + + /** The name of the person. */ + this.name = name; + }, + + /** + @memberof Person# + @param {string} message + */ + say: function(message) { + + /** The person's message. */ + this.message = message; + } +}); diff --git a/test/cases/projecttag.js b/test/cases/projecttag.js new file mode 100644 index 00000000..b00c8e2c --- /dev/null +++ b/test/cases/projecttag.js @@ -0,0 +1,9 @@ +/** + An automated documentation generator for JavaScript. + @project JSDoc + @version 3.0.0 + @copyright 2011 (c) Michael Mathews + @license Apache Version 2 + */ +function blah(url) { +} \ No newline at end of file diff --git a/test/runner.js b/test/runner.js index 211289f0..e496e17f 100644 --- a/test/runner.js +++ b/test/runner.js @@ -95,6 +95,7 @@ testFile('test/t/cases/authortag.js'); testFile('test/t/cases/classtag.js'); testFile('test/t/cases/constructstag.js'); testFile('test/t/cases/constructstag2.js'); +testFile('test/t/cases/constructstag3.js'); testFile('test/t/cases/constructortag.js'); testFile('test/t/cases/copyrighttag.js'); testFile('test/t/cases/deprecatedtag.js'); diff --git a/test/t/cases/constructstag3.js b/test/t/cases/constructstag3.js new file mode 100644 index 00000000..5e7a9649 --- /dev/null +++ b/test/t/cases/constructstag3.js @@ -0,0 +1,12 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag3.js'), + personName = docSet.getByLongname('Person#name')[0]; + + //dump(docSet.doclets); exit(0); + + test('When a function symbol has an @constructs tag, any this-variables are ducumented as instance members of the class.', function() { + assert.equal(personName.memberof, 'Person'); + assert.equal(personName.scope, 'instance'); + }); + +})(); \ No newline at end of file diff --git a/test/t/cases/modules/data/mod-1.js b/test/t/cases/modules/data/mod-1.js index 3ba77be5..6f26452f 100644 --- a/test/t/cases/modules/data/mod-1.js +++ b/test/t/cases/modules/data/mod-1.js @@ -12,7 +12,7 @@ test('When a module has no name documented, the name comes from the file path.', function() { assert.ok(doclets.length > 1); - assert.equal(doclets[0].name, 'module:data/mod-1'); + assert.equal(doclets[0].longname, 'module:data/mod-1'); }); })(); \ No newline at end of file diff --git a/test/t/cases/modules/data/mod-2.js b/test/t/cases/modules/data/mod-2.js index d4dcf9c2..5aff85ab 100644 --- a/test/t/cases/modules/data/mod-2.js +++ b/test/t/cases/modules/data/mod-2.js @@ -12,7 +12,7 @@ test('When a module has a name documented, that name is used.', function() { assert.ok(doclets.length > 1); - assert.equal(doclets[0].name, 'module:my/module/name'); + assert.equal(doclets[0].longname, 'module:my/module/name'); }); })(); \ No newline at end of file diff --git a/test/t/cases/projecttag.js b/test/t/cases/projecttag.js new file mode 100644 index 00000000..5e7a9649 --- /dev/null +++ b/test/t/cases/projecttag.js @@ -0,0 +1,12 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/constructstag3.js'), + personName = docSet.getByLongname('Person#name')[0]; + + //dump(docSet.doclets); exit(0); + + test('When a function symbol has an @constructs tag, any this-variables are ducumented as instance members of the class.', function() { + assert.equal(personName.memberof, 'Person'); + assert.equal(personName.scope, 'instance'); + }); + +})(); \ No newline at end of file