esdoc icon indicating copy to clipboard operation
esdoc copied to clipboard

Add new @enum tag

Open raveclassic opened this issue 10 years ago • 15 comments

Hi!

Current JSDoc spec allows documenting plain objects as enumerables. This is very helpful when restricting argument types.

An abstract example:

//Season.js
/**
 * @enum {String}
 */
const Season = {
    SPRING: 'SPRING',
    SUMMER: 'SUMMER',
    AUTUMN: 'AUTUMN',
    WINTER: 'WINTER'
};

export default Season;
//Forecast.js
export default class Forecast {
    /**
     * @param {Season} season
     */
    generate(season) {
        //implementation
    }
}
//test.js
import Season from './Season.js';
import Forecast from './Forecast.js';

let forecast = new Forecast();
forecast.generate(Season.SUMMER);

Current implementation of ESDoc treats season argument of Forecast#generate as a variable import Season from './Season.js' instead of const Season inside Season.js.

Is it planned to support @enum annotations similar to @typedef?

raveclassic avatar Sep 28 '15 08:09 raveclassic

@raveclassic Hi! Thanks for this proposal. I think that @enum is good. I will try to support it in future version. But now I have no time :sweat: Please wait a moment. Thanks.

h13i32maru avatar Oct 04 '15 13:10 h13i32maru

Any updates to this?

thomasconner avatar Jan 27 '16 16:01 thomasconner

We use them a lot

pronebird avatar Mar 10 '17 12:03 pronebird

Any updates to this?

kylekao1106 avatar May 19 '17 02:05 kylekao1106

Hey! Any news about this feature?

Piroru avatar Jun 16 '17 04:06 Piroru

@Piroru Just switch to typedoc. TS now is able to process js-files and read jsdoc in them.

raveclassic avatar Jun 16 '17 08:06 raveclassic

@raveclassic thanks, we will try it :)

Piroru avatar Jun 16 '17 10:06 Piroru

@Piroru We went even further and rewrote our entire codebase in typescript - it's not that hard ;)

raveclassic avatar Jun 16 '17 11:06 raveclassic

@raveclassic We had an attempt before, I guess we need one more try :D

Piroru avatar Jun 16 '17 13:06 Piroru

+1 on this

robertmain avatar Oct 09 '17 20:10 robertmain

+1 @enum and @event are two missing tag that will make this tool awesome

krvikash35 avatar Oct 20 '17 11:10 krvikash35

We still need this :)

Lenophie avatar Jun 29 '18 16:06 Lenophie

I'm also pretty interested by this feature. Please can you also consider this kind of writing :

static get Eases() {
        return {
            LINEAR: 'Linear',
            ACCELERATE: 'Expo.easeIn',
            DECELERATE: 'Expo.easeOut',
            SINE: 'Sine.easeInOut',
            CIRCULAR: 'Circ.easeInOut',
            ELASTIC: 'Elastic',
            BOUNCE: 'Bounce',
            INERTIA: 'Back.easeOut',
            STEPPED: 'Stepped'
        }
    }

To create an enum embedded in a class. :-)

YannCaron avatar Nov 23 '18 15:11 YannCaron

Any updates on this ?

johnsudaar avatar Apr 03 '19 10:04 johnsudaar

@raveclassic That sounds like a great idea - would love some tips on how to do this. I was able to get ESDoc up and running super easily but I have been unable to figure out how to do the same with typedoc, it just spits out an empty template page.

elashpear avatar May 07 '19 00:05 elashpear