From 2164532d302133dbb1f200e172d0e40ae74e4b2c Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 16 Jul 2017 20:35:47 -0700 Subject: [PATCH] support the `unrestricted` tag (Closure Compiler only) (#605) --- lib/jsdoc/tag/dictionary/definitions.js | 6 +++- test/fixtures/unrestrictedtag.js | 7 +++++ test/specs/tags/unrestrictedtag.js | 42 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/unrestrictedtag.js create mode 100644 test/specs/tags/unrestrictedtag.js diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index 46e4dbdd..d7f77293 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -983,7 +983,11 @@ exports.closureTags = { type: cloneTagDef(baseTags.type, { mustNotHaveDescription: false }), - typedef: cloneTagDef(baseTags.typedef) + typedef: cloneTagDef(baseTags.typedef), + // Closure Compiler only + unrestricted: { + onTagged: ignore + } }; function addTagDefinitions(dictionary, tagDefs) { diff --git a/test/fixtures/unrestrictedtag.js b/test/fixtures/unrestrictedtag.js new file mode 100644 index 00000000..80a836fa --- /dev/null +++ b/test/fixtures/unrestrictedtag.js @@ -0,0 +1,7 @@ +/** + * My class. + * + * @constructor + * @unrestricted + */ +function Foo() {} diff --git a/test/specs/tags/unrestrictedtag.js b/test/specs/tags/unrestrictedtag.js new file mode 100644 index 00000000..ceb049f9 --- /dev/null +++ b/test/specs/tags/unrestrictedtag.js @@ -0,0 +1,42 @@ +'use strict'; + +describe('@unrestricted 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 @unrestricted tag', function() { + jasmine.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); + + expect(logger.error).toHaveBeenCalled(); + }); + }); + + describe('Closure Compiler tags', function() { + beforeEach(function() { + jasmine.replaceTagDictionary('closure'); + }); + + it('should recognize the @unrestricted tag', function() { + jasmine.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); + + expect(logger.error).not.toHaveBeenCalled(); + }); + }); +});