Skip to content

Commit

Permalink
support the nosideeffects tag (Closure Compiler only) (jsdoc#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
hegemonic committed Jul 22, 2017
1 parent 2f99af8 commit 7738610
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/nosideeffectstag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* A function that does nothing.
* @nosideeffects
*/
function doNothing() {}
21 changes: 21 additions & 0 deletions test/specs/tags/nosideeffectstag.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});

0 comments on commit 7738610

Please sign in to comment.