Can't document enums

I am trying to document an enum like this:

/**
 * Enum for the different types of tokens
 * @memberof Ecre
 * @enum {number}
 * @readonly
 */
Ecre.TokenTypes = Object.freeze({
    /**
     * A string token
     */
    "string": 1,
    "comment": 2,
    "number": 3,
    "boolean": 4,
    "identifier": 5
});

      

But this does not work as an exception: it string

is the document as global.

How can I achieve that the values ​​are properly documented?

I am using JSDoc 3.3.0-alpha9 (Sat, 28 Jun 2014 15:26:03 GMT)

+3


source to share


2 answers


This is a pretty old question, but the answer might still be helpful. Since Object.freeze hangs on an object, you can call it after defining the enum.



/**
 * Enum for the different types of tokens
 * @memberof Ecre
 * @enum {number}
 * @readonly
 */
Ecre.TokenTypes = {
    "string": 1,
    "comment": 2,
    "number": 3,
    "boolean": 4,
    "identifier": 5
};
Object.freeze(Ecre.TokenTypes);

      

+4


source


This is how I did it in my code and it works ...

/**
 * Enum: Alignment values
 *
 * @property {Number} Bottom
 * @property {Number} BottomLeft
 * @property {Number} BottomRight
 * @property {Number} Center
 * @property {Number} Left
 * @property {Number} Right
 * @property {Number} Top
 * @property {Number} TopLeft
 * @property {Number} TopRight
 *
 * @enum {Number}
 * @readOnly
 * @memberOf gc
 */
var Align = Object.freeze({
    Bottom      : 0,
    BottomLeft  : 1,
    BottomRight : 2,
    Center      : 3,
    Left        : 4,
    Right       : 5,
    Top         : 6,
    TopLeft     : 7,
    TopRight    : 8
});

gc.Align = Align;

      



The problem is that when used, the Object.freeze

enum is not automatically handled by jsdoc, but with a simple macro in your favorite text editor, the tags @property

can be generated easily ...

Not the best option, but at least the generated documentation is the same

0


source







All Articles