diff --git a/jsdoc b/jsdoc index 823fcab6..968a60af 100755 --- a/jsdoc +++ b/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} $@ \ No newline at end of file diff --git a/rhino_modules/jsdoc/name.js b/rhino_modules/jsdoc/name.js index 0d33902f..5a6d7a32 100644 --- a/rhino_modules/jsdoc/name.js +++ b/rhino_modules/jsdoc/name.js @@ -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; } diff --git a/rhino_modules/jsdoc/src/handlers.js b/rhino_modules/jsdoc/src/handlers.js index 0982b6ec..76051e6c 100644 --- a/rhino_modules/jsdoc/src/handlers.js +++ b/rhino_modules/jsdoc/src/handlers.js @@ -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; diff --git a/rhino_modules/jsdoc/src/parser.js b/rhino_modules/jsdoc/src/parser.js index c41765ff..8e4daa95 100644 --- a/rhino_modules/jsdoc/src/parser.js +++ b/rhino_modules/jsdoc/src/parser.js @@ -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); } diff --git a/test/cases/exportstag4.js b/test/cases/exportstag4.js new file mode 100644 index 00000000..3097a565 --- /dev/null +++ b/test/cases/exportstag4.js @@ -0,0 +1,12 @@ +define( + /** @exports some/module */ + function () { + /** @class */ + function myClass() {} + + /** Some method */ + myClass.prototype.myMethod = function () {}; + + return new myClass(); + } +); \ No newline at end of file diff --git a/test/runner.js b/test/runner.js index 6d382fb5..ffeccb62 100644 --- a/test/runner.js +++ b/test/runner.js @@ -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'); diff --git a/test/t/cases/exportstag4.js b/test/t/cases/exportstag4.js new file mode 100644 index 00000000..fa230c1a --- /dev/null +++ b/test/t/cases/exportstag4.js @@ -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'); + }); + +})(); \ No newline at end of file