Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use jsdoc on js with flow type annotations

When trying to process js sources with flow type annotations the jsdoc parser failes to understand the enhanced syntax! Is there a way to use jsdoc in js sources that have been enhanced with flow type annotations or what is the recommended way to generate documentation from type annotated js?

like image 525
doberkofler Avatar asked Aug 26 '16 09:08

doberkofler


2 Answers

Just started using documentation.js. Supports JSdoc and flow out of the box.

like image 109
Eric H. Avatar answered Oct 02 '22 15:10

Eric H.


You could use babel with strip-flow-types transform and use jsdoc-babel.

First, you need to install babel and related packages and jsdoc-babel on top of jsdoc. Then, create a jsdoc-conf.json file in your root directory containing something like this:

{
    "plugins": ["node_modules/jsdoc-babel"],
    "babel": {
        "presets": ["react"],
        "plugins": ["transform-react-jsx", "transform-flow-strip-types"]
    }
}

Usage: jsdoc -c jsdoc-conf.json

You can use any valid babel setup with jsdoc-babel under "babel" that is applied in addition to your .babelrc file. e.g. presets for ES2015 or other babel plugins. Hope this helps!

like image 28
sami Avatar answered Oct 02 '22 15:10

sami