From e45a719cd09ad08a5b08ee3b195579c754bba936 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 16 Jul 2017 18:21:19 -0700 Subject: [PATCH] support the `implicitCast` tag (Closure Compiler only) (#605) --- lib/jsdoc/tag/dictionary/definitions.js | 4 +++ test/fixtures/implicitcasttag.js | 7 +++++ test/specs/tags/implicitcasttag.js | 42 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/fixtures/implicitcasttag.js create mode 100644 test/specs/tags/implicitcasttag.js diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index d52bc434..39a66dd2 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -882,6 +882,10 @@ exports.closureTags = { }, final: cloneTagDef(baseTags.readonly), implements: cloneTagDef(baseTags.implements), + // Closure Compiler only + implicitcast: { + onTagged: ignore + }, inheritdoc: cloneTagDef(baseTags.inheritdoc), interface: cloneTagDef(baseTags.interface, { canHaveName: false, diff --git a/test/fixtures/implicitcasttag.js b/test/fixtures/implicitcasttag.js new file mode 100644 index 00000000..3bd8b8df --- /dev/null +++ b/test/fixtures/implicitcasttag.js @@ -0,0 +1,7 @@ +function Foo() {} + +/** + * @type {string} + * @implicitCast + */ +Foo.prototype.bar; diff --git a/test/specs/tags/implicitcasttag.js b/test/specs/tags/implicitcasttag.js new file mode 100644 index 00000000..7b8d2bbd --- /dev/null +++ b/test/specs/tags/implicitcasttag.js @@ -0,0 +1,42 @@ +'use strict'; + +describe('@implicitCast 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 @implicitCast tag', function() { + jasmine.getDocSetFromFile('test/fixtures/implicitcasttag.js'); + + expect(logger.error).toHaveBeenCalled(); + }); + }); + + describe('Closure Compiler tags', function() { + beforeEach(function() { + jasmine.replaceTagDictionary('closure'); + }); + + it('should recognize the @implicitCast tag', function() { + jasmine.getDocSetFromFile('test/fixtures/implicitcasttag.js'); + + expect(logger.error).not.toHaveBeenCalled(); + }); + }); +});