diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index 6ba8a95c2..681fff906 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -898,6 +898,10 @@ exports.closureTags = { onTagged: ignore }, // Closure Compiler only + nocollapse: { + onTagged: ignore + }, + // Closure Compiler only override: { mustNotHaveValue: true, onTagged: function(doclet) { diff --git a/test/fixtures/nocollapsetag.js b/test/fixtures/nocollapsetag.js new file mode 100644 index 000000000..3676b8371 --- /dev/null +++ b/test/fixtures/nocollapsetag.js @@ -0,0 +1,8 @@ +/** + * A namespace. + * @const + */ +var foo = {}; + +/** @nocollapse */ +foo.bar = true; diff --git a/test/specs/tags/nocollapsetag.js b/test/specs/tags/nocollapsetag.js new file mode 100644 index 000000000..b0265dca4 --- /dev/null +++ b/test/specs/tags/nocollapsetag.js @@ -0,0 +1,42 @@ +'use strict'; + +describe('@nocollapse tag', function() { + var env = require('jsdoc/env'); + var logger = require('jsdoc/util/logger'); + + var allowUnknownTags = Boolean(env.conf.tags.allowUnknownTags); + + beforeEach(function() { + env.conf.tags.allowUnknownTags = false; + spyOn(logger, 'error'); + }); + + afterEach(function() { + jasmine.restoreTagDictionary(); + env.conf.tags.allowUnknownTags = allowUnknownTags; + }); + + describe('JSDoc tags', function() { + beforeEach(function() { + jasmine.replaceTagDictionary('jsdoc'); + }); + + it('should not recognize the @nocollapse tag', function() { + jasmine.getDocSetFromFile('test/fixtures/nocollapsetag.js'); + + expect(logger.error).toHaveBeenCalled(); + }); + }); + + describe('Closure Compiler tags', function() { + beforeEach(function() { + jasmine.replaceTagDictionary('closure'); + }); + + it('should recognize the @nocollapse tag', function() { + jasmine.getDocSetFromFile('test/fixtures/nocollapsetag.js'); + + expect(logger.error).not.toHaveBeenCalled(); + }); + }); +});