The event namespace is now optional for symbols mentioned in @fires tags. Closes #40.

This commit is contained in:
Michael Mathews 2011-10-07 20:42:23 +01:00
parent df45f945b4
commit 7d840bcaa3
5 changed files with 56 additions and 6 deletions

2
jsdoc
View File

@ -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} $@
#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} $@

View File

@ -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) {

View File

@ -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', {});
};

View File

@ -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');

View File

@ -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');
});
})();