added @listens tag (need to add to template too)

This commit is contained in:
mathematicalcoffee 2013-02-15 16:27:02 +10:00
parent 21dbd5804f
commit 5ffaaff619
2 changed files with 20 additions and 0 deletions

View File

@ -405,6 +405,15 @@ exports.defineTags = function(dictionary) {
}
});
dictionary.defineTag('listens', {
mustHaveValue: true,
onTagged: function (doclet, tag) {
if (!doclet.listens) { doclet.listens = []; }
doclet.listens.push(tag.value);
// TODO: verify that parameters match the event parameters?
}
});
dictionary.defineTag('member', {
canHaveType: true,
onTagged: function(doclet, tag) {

View File

@ -0,0 +1,11 @@
describe("@listens tag", function() {
var doclet = require('jsdoc/doclet'),
doc = new doclet.Doclet('/** An event handler\n@function handler\n@listens Foo\n@listens Bar */', {});
it("should create a 'listens' property on the doclet, an array, with the events that are listened to", function() {
expect(Array.isArray(doc.listens)).toBeTruthy();
expect(doc.listens.length).toBe(2);
expect(doc.listens).toContain('Foo');
expect(doc.listens).toContain('Bar');
});
});