mirror of
https://github.com/jsdoc/jsdoc.git
synced 2026-01-25 15:24:34 +00:00
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:
parent
8afd06613f
commit
34d98ed438
@ -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', {
|
||||
|
||||
@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user