mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Inner functions are now tracked, same as inner vars. Fixes bug where some inner functions were not documented as members of their enclosing function. Closes #30.
This commit is contained in:
parent
e92a6ccbfe
commit
dfe7474ece
2
jsdoc
2
jsdoc
@ -3,6 +3,6 @@
|
||||
# rhino discards the path to the current script file, so we must add it back
|
||||
PWD=`pwd`
|
||||
BASEDIR=`dirname $0`
|
||||
java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main -debug ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
|
||||
#java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.debugger.Main -debug ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@
|
||||
@ -19,7 +19,6 @@
|
||||
@param {module:jsdoc/doclet.Doclet} doclet
|
||||
*/
|
||||
exports.resolve = function(doclet) {
|
||||
|
||||
var name = doclet.name,
|
||||
memberof = doclet.memberof || '',
|
||||
about = {},
|
||||
@ -49,7 +48,7 @@
|
||||
else { // no @memberof
|
||||
about = exports.shorten(name);
|
||||
}
|
||||
|
||||
|
||||
if (about.name) {
|
||||
doclet.name = about.name;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
var nameStartsWith = RegExp.$1;
|
||||
|
||||
newDoclet.name = newDoclet.name.replace(/^(exports|this)(\.|$)/, '');
|
||||
|
||||
|
||||
// like /** @module foo */ exports.bar = 1;
|
||||
if (nameStartsWith === 'exports' && currentModule) {
|
||||
memberofName = currentModule;
|
||||
|
||||
@ -210,9 +210,8 @@
|
||||
enclosingFunction = node.enclosingFunction;
|
||||
|
||||
if (!enclosingFunction) { return ''; } // global
|
||||
|
||||
doclet = this.refs['astnode'+enclosingFunction.hashCode()];
|
||||
|
||||
|
||||
if ( doclet && doclet.meta.vars && ~doclet.meta.vars.indexOf(basename) ) {
|
||||
return doclet.longname;
|
||||
}
|
||||
@ -258,6 +257,7 @@
|
||||
};
|
||||
|
||||
var basename = e.code.name.replace(/^([$a-z_][$a-z_0-9]*).*?$/i, '$1');
|
||||
|
||||
if (basename !== 'this') e.code.funcscope = currentParser.resolveVar(node, basename);
|
||||
|
||||
if ( isValidJsdoc(e.comment) ) {
|
||||
@ -334,9 +334,23 @@
|
||||
astnode: node,
|
||||
code: aboutNode(node)
|
||||
};
|
||||
|
||||
|
||||
e.code.name = String(node.name) || '';
|
||||
|
||||
// keep track of vars in a function scope
|
||||
if (node.enclosingFunction) {
|
||||
var func = 'astnode'+node.enclosingFunction.hashCode(),
|
||||
funcDoc = currentParser.refs[func];
|
||||
|
||||
if (funcDoc) {
|
||||
funcDoc.meta.vars = funcDoc.meta.vars || [];
|
||||
funcDoc.meta.vars.push(e.code.name);
|
||||
}
|
||||
}
|
||||
|
||||
var basename = e.code.name.replace(/^([$a-z_][$a-z_0-9]*).*?$/i, '$1');
|
||||
e.code.funcscope = currentParser.resolveVar(node, basename);
|
||||
|
||||
if ( isValidJsdoc(e.comment) ) {
|
||||
currentParser.fire('symbolFound', e, currentParser);
|
||||
}
|
||||
|
||||
12
test/cases/exportstag4.js
Normal file
12
test/cases/exportstag4.js
Normal file
@ -0,0 +1,12 @@
|
||||
define(
|
||||
/** @exports some/module */
|
||||
function () {
|
||||
/** @class */
|
||||
function myClass() {}
|
||||
|
||||
/** Some method */
|
||||
myClass.prototype.myMethod = function () {};
|
||||
|
||||
return new myClass();
|
||||
}
|
||||
);
|
||||
@ -120,6 +120,7 @@ testFile('test/t/cases/exports.js');
|
||||
testFile('test/t/cases/exportstag.js');
|
||||
testFile('test/t/cases/exportstag2.js');
|
||||
testFile('test/t/cases/exportstag3.js');
|
||||
testFile('test/t/cases/exportstag4.js');
|
||||
testFile('test/t/cases/exceptiontag.js');
|
||||
testFile('test/t/cases/globaltag.js');
|
||||
testFile('test/t/cases/ignoretag.js');
|
||||
|
||||
17
test/t/cases/exportstag4.js
Normal file
17
test/t/cases/exportstag4.js
Normal file
@ -0,0 +1,17 @@
|
||||
(function() {
|
||||
var docSet = testhelpers.getDocSetFromFile('test/cases/exportstag4.js'),
|
||||
module = docSet.getByLongname('module:some/module')[0],
|
||||
innerClass = docSet.getByLongname('module:some/module~myClass')[0],
|
||||
method = docSet.getByLongname('module:some/module~myClass#myMethod')[0];
|
||||
|
||||
test('An inner class declared as a function in a module should be documented.', function() {
|
||||
assert.equal(typeof innerClass, 'object');
|
||||
//assert.equal(getstyle.memberof, 'module:html/utils');
|
||||
});
|
||||
|
||||
test('A method of an inner class declared as a function in a module should be documented.', function() {
|
||||
assert.equal(typeof method, 'object');
|
||||
//assert.equal(inhead.memberof, 'module:html/utils');
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user