Members of enum automatically get a default value.

This commit is contained in:
Michael Mathews 2011-10-27 00:20:33 +01:00
parent 2351776bdf
commit ce435bed51
3 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,7 @@
{
"name": "JSDoc",
"version": "3.0.0alpha",
"revision": "1319151616566",
"revision": "1319671194463",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [

View File

@ -319,6 +319,7 @@ function visitNode(node) {
// members of an enum inherit the enum's type
if (parent.doclet.type && !e.doclet.type) { e.doclet.type = parent.doclet.type; }
delete e.doclet.undocumented;
e.doclet.defaultvalue = e.doclet.meta.code.value;
parent.doclet.properties.push(e.doclet);
}
}
@ -511,6 +512,9 @@ function nodeToString(node) {
else if (node.type === Token.GETELEM) {
str = node.toSource(); // like: Foo['Bar']
}
else if (node.type === Token.NEG || node.type === Token.TRUE || node.type === Token.FALSE) {
str = node.toSource(); // like -1
}
else {
str = getTypeName(node);
}

View File

@ -15,7 +15,10 @@
test('If no no comment is given for the property it is still included in the enum.', function() {
assert.equal(tristate.properties[1].longname, 'TriState.FALSE');
assert.equal(typeof tristate.properties[1].undocumented, 'undefined');
});
test('A property of an enum gets its defaultvalue set.', function() {
assert.equal(tristate.properties[1].defaultvalue, -1);
});
test('If a @type is given for the property it is reflected in the property value.', function() {