automatically treat const declarations as constants (#555)

This commit is contained in:
Jeff Williams 2015-01-30 07:58:36 -08:00
parent 2e1a209815
commit 62f563d730
4 changed files with 22 additions and 0 deletions

View File

@ -281,6 +281,11 @@ function newSymbolDoclet(parser, docletSrc, e) {
newDoclet.scope = SCOPE_NAMES.GLOBAL;
}
// handle cases where the doclet kind is auto-detected from the node type
if (e.code.kind) {
newDoclet.kind = e.code.kind;
}
addDoclet(parser, newDoclet);
e.doclet = newDoclet;
}

View File

@ -388,6 +388,10 @@ Visitor.prototype.makeSymbolFoundEvent = function(node, parser, filename) {
trackVars(parser, node, e);
basename = parser.getBasename(e.code.name);
// auto-detect constants
if (node.parent.kind === 'const') {
e.code.kind = 'constant';
}
break;

View File

@ -13,3 +13,6 @@ var mySocket;
/** @const ROCKET */
var myRocket;
/** auto-detected const */
const myPocket = 1;

View File

@ -0,0 +1,10 @@
'use strict';
describe('const declarations', function() {
it('should automatically set the doclet.kind to "constant" for const declarations', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag.js');
var myPocket = docSet.getByLongname('myPocket')[0];
expect(myPocket.kind).toBe('constant');
});
});