Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to document a javascript plain object using ESDOC?

It seems that ESDOC targets only ES6 class style.

Is there a way to document a plain object like:

/**
 * ???
 */
var Foo = {
    /**
     * ???
     */
    info: true
};

export default Foo;

And even when using ES6 class style, how to document a static property like:

class Bar {
}

/**
 * ???
 */
Bar.info = true;

export default Bar;
like image 825
Stéphane Francel Avatar asked Dec 29 '16 23:12

Stéphane Francel


2 Answers

Short answer. No.

ESDOC is designed specifically to document ES6 classes. It's right in the name. From the FAQ:

ESDoc supports ES2015 and later

If you need to document a mixture of ES6+ and regular (prototypal) classes, JSDOC might be a better bet. It's fairly mature and it's format is a sort of defacto standard.

If you don't like or can't use the main JSDOC package, there are plenty of other options. Just for example, I've had success with jsdoc-to-markdown on my projects. You should be able to find the tools to convert JSDOC to whatever format you need.

like image 171
leff Avatar answered Nov 19 '22 10:11

leff


For member and variable you should use @type

/**
* @type {Object}
* @property {boolean} Foo.info describe Foo.info
*/
const Foo = {
   info: true
};

and for static properties in es6 you should use className.method_member

/**
* This is Bar description.
*/
class Bar {
  /**
  * Bar.info
  */
  static info=true
}

check esdoc output here

like image 35
fingerpich Avatar answered Nov 19 '22 08:11

fingerpich