Skip to content

Commit afe7c35

Browse files
committed
support the externs tag (Closure Compiler only) (jsdoc#605)
1 parent d06ba27 commit afe7c35

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

lib/jsdoc/tag/dictionary/definitions.js

+4
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,10 @@ exports.closureTags = {
866866
export: {
867867
onTagged: ignore
868868
},
869+
// Closure Compiler only
870+
externs: {
871+
onTagged: ignore
872+
},
869873
extends: cloneTagDef(baseTags.augments),
870874
final: cloneTagDef(baseTags.readonly),
871875
implements: cloneTagDef(baseTags.implements),

test/fixtures/externstag.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* This is an externs file.
3+
*
4+
* @externs
5+
*/

test/specs/externstag.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
describe('@externs tag', function() {
4+
var env = require('jsdoc/env');
5+
var logger = require('jsdoc/util/logger');
6+
7+
var allowUnknownTags = Boolean(env.conf.tags.allowUnknownTags);
8+
9+
beforeEach(function() {
10+
env.conf.tags.allowUnknownTags = false;
11+
spyOn(logger, 'error');
12+
});
13+
14+
afterEach(function() {
15+
jasmine.restoreTagDictionary();
16+
env.conf.tags.allowUnknownTags = allowUnknownTags;
17+
});
18+
19+
describe('JSDoc tags', function() {
20+
beforeEach(function() {
21+
jasmine.replaceTagDictionary('jsdoc');
22+
});
23+
24+
it('should not recognize the @externs tag', function() {
25+
jasmine.getDocSetFromFile('test/fixtures/externstag.js');
26+
27+
expect(logger.error).toHaveBeenCalled();
28+
});
29+
});
30+
31+
describe('Closure Compiler tags', function() {
32+
beforeEach(function() {
33+
jasmine.replaceTagDictionary('closure');
34+
});
35+
36+
it('should recognize the @externs tag', function() {
37+
jasmine.getDocSetFromFile('test/fixtures/externstag.js');
38+
39+
expect(logger.error).not.toHaveBeenCalled();
40+
});
41+
});
42+
});

0 commit comments

Comments
 (0)