mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
automatically treat const declarations as constants (#555)
This commit is contained in:
parent
2e1a209815
commit
62f563d730
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
3
test/fixtures/constanttag.js
vendored
3
test/fixtures/constanttag.js
vendored
@ -13,3 +13,6 @@ var mySocket;
|
||||
|
||||
/** @const ROCKET */
|
||||
var myRocket;
|
||||
|
||||
/** auto-detected const */
|
||||
const myPocket = 1;
|
||||
|
||||
10
test/specs/documentation/const.js
Normal file
10
test/specs/documentation/const.js
Normal 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');
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user