diff --git a/jsdoc b/jsdoc index 509b480e..89cc407c 100755 --- a/jsdoc +++ b/jsdoc @@ -5,4 +5,4 @@ PWD=`pwd` BASEDIR=`dirname $0` java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules ${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 +#java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.debugger.Main -debug -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules ${BASEDIR}/jsdoc.js ${BASEDIR}/jsdoc.js --dirname=${PWD}/${BASEDIR} $@ \ No newline at end of file diff --git a/rhino_modules/jsdoc/tag/dictionary/definitions.js b/rhino_modules/jsdoc/tag/dictionary/definitions.js index b1a70acd..62e09b40 100644 --- a/rhino_modules/jsdoc/tag/dictionary/definitions.js +++ b/rhino_modules/jsdoc/tag/dictionary/definitions.js @@ -229,6 +229,7 @@ exports.defineTags = function(dictionary) { mustHaveValue: true, onTagged: function(doclet, tag) { if (!doclet.fires) { doclet.fires = []; } + applyNamespace('event', tag); doclet.fires.push(tag.value); } }); @@ -540,11 +541,16 @@ function setDocletMemberof(doclet, tag) { doclet.setMemberof(tag.value); } -function applyNamespace(doclet, tag) { - if (!doclet.name) return; // error? - - //doclet.displayname = doclet.name; - doclet.longname = app.jsdoc.name.applyNamespace(doclet.name, tag.title) +function applyNamespace(docletOrNs, tag) { + if (typeof docletOrNs === 'string') { // ns + tag.value = app.jsdoc.name.applyNamespace(tag.value, docletOrNs); + } + else { // doclet + if (!docletOrNs.name) return; // error? + + //doclet.displayname = doclet.name; + docletOrNs.longname = app.jsdoc.name.applyNamespace(docletOrNs.name, tag.title); + } } function setDocletNameToFilename(doclet, tag) { diff --git a/test/cases/eventfirestag.js b/test/cases/eventfirestag.js new file mode 100644 index 00000000..4fe3e746 --- /dev/null +++ b/test/cases/eventfirestag.js @@ -0,0 +1,18 @@ +/** + * @class + */ +var Hurl = function () { +}; + +/** + * Throw a snowball. + * + * @fires Hurl#snowball + * @fires Hurl#event:brick + */ +Hurl.prototype.snowball = function () { + /** + * @event Hurl#snowball + */ + this.emit('snowball', {}); +}; diff --git a/test/runner.js b/test/runner.js index 72c85c8f..cc256c4f 100644 --- a/test/runner.js +++ b/test/runner.js @@ -123,6 +123,7 @@ testFile('test/t/cases/constructortag.js'); testFile('test/t/cases/copyrighttag.js'); testFile('test/t/cases/defaulttag.js'); testFile('test/t/cases/deprecatedtag.js'); +testFile('test/t/cases/eventfirestag.js'); testFile('test/t/cases/exports.js'); testFile('test/t/cases/exportstag.js'); testFile('test/t/cases/exportstag2.js'); diff --git a/test/t/cases/eventfirestag.js b/test/t/cases/eventfirestag.js new file mode 100644 index 00000000..c78c3421 --- /dev/null +++ b/test/t/cases/eventfirestag.js @@ -0,0 +1,25 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/eventfirestag.js'), + snowballMethod = docSet.getByLongname('Hurl#snowball')[0], + snowballEvent = docSet.getByLongname('Hurl#event:snowball')[0]; + + //console.log(docSet); + + // @event tag + test('When a symbol has an @event tag, the doclet is of kind "event".', function() { + assert.equal(snowballEvent.kind, 'event'); + }); + + // @fires tag + test('When a symbol has a @fires tag, the doclet has an array named "fires".', function() { + assert.equal(typeof snowballMethod.fires, 'object'); + }); + + test('When a symbol has a fires array, the members have the event namespace.', function() { + assert.equal(snowballMethod.fires[0], 'Hurl#event:snowball'); + }); + + test('When a symbol has a fires array with a name that already has an event: namespace, it doesn\'t have a secong namespace applied.', function() { + assert.equal(snowballMethod.fires[1], 'Hurl#event:brick'); + }); +})(); \ No newline at end of file