Added support in default template for modules that are also classes.

This commit is contained in:
Michael Mathews 2011-06-23 21:50:09 +01:00
parent a8cd6b59de
commit 51c8046fcc
4 changed files with 37 additions and 3 deletions

3
node_modules/jsdoc/tag.js generated vendored
View File

@ -107,8 +107,9 @@
/**
Parse the parameter name and parameter desc from the tag text.
@private
@inner
@method parseParamText
@memberof module:jsdoc/tag
@param {string} tagText
@returns {Array.<string, string, boolean, boolean>} [pname, pdesc, poptional, pdefault].
*/

View File

@ -220,6 +220,7 @@
nav = nav + '</ul>';
}
var namespaceNames = data.get( data.find({kind: 'namespace'}) );
if (namespaceNames.length) {
nav = nav + '<h3>Namespaces</h3><ul>';
@ -230,17 +231,25 @@
nav = nav + '</ul>';
}
var classNames = data.get( data.find({kind: 'class'}) );
if (classNames.length) {
nav = nav + '<h3>Classes</h3><ul>';
classNames.forEach(function(c) {
if ( !seen.hasOwnProperty(c.longname) ) nav += '<li>'+linkto(c.longname, c.name)+'</li>';
var moduleSameName = data.get( data.find({kind: 'module', longname: c.longname}) );
if (moduleSameName) {
c.name = c.name.replace('module:', 'require(')+')';
moduleSameName[0].module = c;
}
if (!seen.hasOwnProperty(c.longname) ) nav += '<li>'+linkto(c.longname, c.name)+'</li>';
seen[c.longname] = true;
});
nav = nav + '</ul>';
}
//console.log('classNames', classNames);
var globalNames = data.get( data.find({kind: ['property', 'function'], 'memberof': {'isUndefined': true}}) );
if (globalNames.length) {

View File

@ -50,6 +50,10 @@
<article>
<?js
if (doc.kind === 'module' && doc.module) {
print(render('method.tmpl', doc.module));
}
if (doc.kind === 'class') {
print(render('method.tmpl', doc));
}

20
test/cases/moduletag3.js Normal file
View File

@ -0,0 +1,20 @@
/**
@module foo/Photo/manager
@desc Manage a collection of photos.
*/
/**
Construct a new Photo manager
@constructor module:foo/Photo/manager
@param {String} collectionId The identifier of the managed collection.
*/
module.exports = function(collectionId) {
/**
@function module:foo/Photo/manager#getPhoto
@param {String} photoName
*/
this.getPhoto = function() {}
}