@kadira/babel-plugin-react-docgen
v1.1.0
Published
Add propType doc to react classes
Downloads
14
Readme
babel-plugin-react-docgen
Add propType doc to react classes
Installation
$ npm install babel-plugin-react-docgen
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["babel-plugin-react-docgen"]
}
Via CLI
$ babel --plugins babel-plugin-react-docgen script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["babel-plugin-react-docgen"]
});
Guide
- React class information is avalable via
<ClassName>.__docgenInfo
as a JSON parsabel string. - This plugin uses
react-docgen
under the hood, so every limitation it has, applies. - If you need a global object with all the react component docs, set plugin options like this in
.babelrc
(replace with variable name you want)
"plugins":[["babel-plugin-react-docgen", {"DOC_GEN_GLOBAL": "<your global name>"}]]