Skip to content

Commit

Permalink
support preserve tag (Closure Compiler only) (jsdoc#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
hegemonic committed Jul 17, 2017
1 parent e810cb7 commit 60143a4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,8 @@ exports.closureTags = {
polymerBehavior: {
onTagged: ignore
},
// Closure Compiler only
preserve: cloneTagDef(baseTags.license),
private: {
canHaveType: true,
onTagged: function(doclet, tag) {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/preservetag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** @preserve My cool license goes here. */
var x;
43 changes: 43 additions & 0 deletions test/specs/tags/preservetag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

describe('@preserve 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 @preserve tag', function() {
jasmine.getDocSetFromFile('test/fixtures/preservetag.js');

expect(logger.error).toHaveBeenCalled();
});
});

describe('Closure Compiler tags', function() {
beforeEach(function() {
jasmine.replaceTagDictionary('closure');
});

it('should set the doclet\'s `license` property to the tag value', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/preservetag.js');
var x = docSet.getByLongname('x')[0];

expect(x.license).toBe('My cool license goes here.');
});
});
});

0 comments on commit 60143a4

Please sign in to comment.