support the nosideeffects tag (Closure Compiler only) (#605)

This commit is contained in:
Jeff Williams 2017-07-21 18:42:53 -07:00
parent 2f99af8fbb
commit 7738610a9f
3 changed files with 32 additions and 0 deletions

View File

@ -931,6 +931,12 @@ exports.closureTags = {
onTagged: ignore
},
// Closure Compiler only
nosideeffects: {
onTagged: function(doclet) {
doclet.modifies = [];
}
},
// Closure Compiler only
override: {
mustNotHaveValue: true,
onTagged: function(doclet) {

5
test/fixtures/nosideeffectstag.js vendored Normal file
View File

@ -0,0 +1,5 @@
/**
* A function that does nothing.
* @nosideeffects
*/
function doNothing() {}

View File

@ -0,0 +1,21 @@
'use strict';
describe('@nosideeffects tag', function() {
afterEach(function() {
jasmine.restoreTagDictionary();
});
describe('Closure Compiler tags', function() {
beforeEach(function() {
jasmine.replaceTagDictionary('closure');
});
it('should set the doclet\'s `modifies` property to an empty array', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/nosideeffectstag.js');
var doNothing = docSet.getByLongname('doNothing')[0];
expect(Array.isArray(doNothing.modifies)).toBe(true);
expect(doNothing.modifies.length).toBe(0);
});
});
});