add @also to tag definitions (#574)

This tag is used internally. It previously caused
"not a known tag" errors when
tags.allowUnknownTags was set to false.
This commit is contained in:
Jeff Williams 2014-02-16 08:39:32 -08:00
parent 8afd06613f
commit 34d98ed438
2 changed files with 41 additions and 1 deletions

View File

@ -164,6 +164,24 @@ exports.defineTags = function(dictionary) {
doclet.alias = tag.value;
}
});
// Special separator tag indicating that multiple doclets should be generated for the same
// comment. Used internally (and by some JSDoc users, although it's not officially supported).
//
// In the following example, the parser will replace `//**` with an `@also` tag:
//
// /**
// * Foo.
// *//**
// * Foo with a param.
// * @param {string} bar
// */
// function foo(bar) {}
dictionary.defineTag('also', {
onTagged: function(doclet, tag) {
// let the parser handle it; we define the tag here to avoid "not a known tag" errors
}
});
// this symbol inherits from the specified symbol
dictionary.defineTag('augments', {

View File

@ -1,4 +1,4 @@
/*global describe: true, expect: true, it: true, jasmine: true */
/*global describe, expect, it, jasmine, spyOn */
describe("multiple doclets per symbol", function() {
function undocumented($) {
return ! $.undocumented;
@ -44,4 +44,26 @@ describe("multiple doclets per symbol", function() {
checkInequality(name, 'returns.length');
checkInequality(shape, 'returns.length');
});
it('When a file contains a JSDoc comment with an @also tag, and the "tags.allowUnknownTags" ' +
'option is set to false, the file can be parsed without errors.', function() {
var logger = require('jsdoc/util/logger');
var allowUnknownTags = !!global.env.conf.tags.allowUnknownTags;
var docs;
var errors = [];
function errorListener(err) {
errors.push(err);
}
logger.addListener('logger:error', errorListener);
global.env.conf.tags.allowUnknownTags = false;
docs = jasmine.getDocSetFromFile('test/fixtures/also2.js');
expect(errors[0]).not.toBeDefined();
logger.removeListener('logger:error', errorListener);
global.env.conf.tags.allowUnknownTags = allowUnknownTags;
});
});