diff --git a/lib/jsdoc/src/handlers.js b/lib/jsdoc/src/handlers.js index 85102ddc..5a76625e 100644 --- a/lib/jsdoc/src/handlers.js +++ b/lib/jsdoc/src/handlers.js @@ -260,7 +260,7 @@ function newSymbolDoclet(parser, docletSrc, e) { processAlias(parser, newDoclet, e.astnode); } // otherwise, get the symbol name from the code - else if (e.code && e.code.name) { + else if (e.code && typeof e.code.name !== 'undefined' && e.code.name !== '') { newDoclet.addTag('name', e.code.name); if (!newDoclet.memberof) { addSymbolMemberof(parser, newDoclet, e.astnode); diff --git a/lib/jsdoc/tag.js b/lib/jsdoc/tag.js index 60a1bf9c..7c9a9a17 100644 --- a/lib/jsdoc/tag.js +++ b/lib/jsdoc/tag.js @@ -38,7 +38,7 @@ function trim(text, opts, meta) { var match; opts = opts || {}; - text = String(text || ''); + text = String(typeof text !== 'undefined' ? text : ''); if ( mustPreserveWhitespace(text, meta) ) { text = util.format('"%s"', text); diff --git a/test/fixtures/enumtag.js b/test/fixtures/enumtag.js index 2374f09e..5d621e85 100644 --- a/test/fixtures/enumtag.js +++ b/test/fixtures/enumtag.js @@ -8,4 +8,14 @@ var TriState = { FALSE: -1, /** @type {boolean} */ MAYBE: true -}; \ No newline at end of file +}; + +/** + * Numeric enum for true/false values. + * @enum {boolean} + */ +var TrueFalseNumeric = { + /** false */ + 0: false, + 1: true +}; diff --git a/test/specs/tags/enumtag.js b/test/specs/tags/enumtag.js index 90f6b091..6d58ee3c 100644 --- a/test/specs/tags/enumtag.js +++ b/test/specs/tags/enumtag.js @@ -31,15 +31,20 @@ describe('@enum tag', function() { expect( dump(tristate) ).not.toMatch(''); }); - describe('chained assignments', function() { - var pentaState; - var PENTASTATE; - var quadState; + describe('numeric object properties', function() { + it('When an enum is defined with numeric object properties, the enum is parsed correctly.', function() { + var zero = docSet.getByLongname('TrueFalseNumeric.0')[0]; - docSet = jasmine.getDocSetFromFile('test/fixtures/enumtag2.js'); - pentaState = docSet.getByLongname('module:my/enums.PentaState')[0]; - PENTASTATE = docSet.getByLongname('module:my/enums.PENTASTATE')[0]; - quadState = docSet.getByLongname('module:my/enums.QuadState')[0]; + expect(zero).toBeDefined(); + expect(zero.description).toBe('false'); + }); + }); + + describe('chained assignments', function() { + var docSet2 = jasmine.getDocSetFromFile('test/fixtures/enumtag2.js'); + var pentaState = docSet2.getByLongname('module:my/enums.PentaState')[0]; + var PENTASTATE = docSet2.getByLongname('module:my/enums.PENTASTATE')[0]; + var quadState = docSet2.getByLongname('module:my/enums.QuadState')[0]; it('When a symbol at the start of an assignment chain has an @enum tag, that symbol has a properties array.', function() { expect( Array.isArray(quadState.properties) ).toBe(true);