From 21583fe8a1570abdda0cde857b66dc0777e0c1fe Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 16 Jul 2017 18:31:08 -0700 Subject: [PATCH] support the `nocollapse` tag (Closure Compiler only) (#605) --- lib/jsdoc/tag/dictionary/definitions.js | 4 +++ test/fixtures/nocollapsetag.js | 8 +++++ test/specs/tags/nocollapsetag.js | 42 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 test/fixtures/nocollapsetag.js create mode 100644 test/specs/tags/nocollapsetag.js diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index 6ba8a95c..681fff90 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 00000000..3676b837 --- /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 00000000..b0265dca --- /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(); + }); + }); +});