Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to document enum values in JS Doc

I am using JS Doc to generate docs for JS. I have an enum with few values. I want to generate docs for each property. I tried the following:

/**
 * Enum for display state.
 * @readonly
 * @enum {string}
 */
var DisplayState = {
    /** @member {string} */
    foreground: 'foreground',
    /** @member {string} */
    background: 'background',
    /** @member {string} */
    projected: 'projected'
};

But after HTML page is generated, I only see doc for enum type not individual properties.

I've tried the following /** some comment */ /** @member {string} */ And /** @property {string} */ but nothing seems to work

like image 704
Sai Avatar asked Aug 25 '26 18:08

Sai


1 Answers

I upgraded to Version 3 of JS Doc (https://github.com/jsdoc3/jsdoc) and this issue was fixed.

See example below:

/**
 * Enum for display state.
 * @readonly
 * @enum {string}
 */
var DisplayState = {
    /** @member {string} */
    /** The app is running in the foreground and can receive user input. */
    foreground: 'foreground',

    /** @member {string} */
    /** The app is in the background and can't receive user input. */
    background: 'background',

    /** @member {string} */
    /** The app is running in Phone Projection mode (Android Auto or Apple Car Play). */
    projected: 'projected'
};
like image 131
Sai Avatar answered Aug 27 '26 07:08

Sai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!