Create documentation for your React projects in an easy way using standard PropTypes declarations.
Share the documentation in your project's repository.
It parses the files using React Docgen. Please refer to its documentation for details.
$ npm install --save-dev react-doc-creator
In your package.json
insert:
{
// ...
"scripts": {
"build:doc": "react-doc-creator"
}
// ...
}
To run it:
$ npm run build:doc
It will search for React Components in your src
folder and write the documentation in a COMPONENTS.md
file
react-doc-creator [path] ...[options]
path A component file or directory. Default: src
Options:
-o, --out <file> Target markdown file. (default: COMPONENTS.md)
-x, --extension <items> Include only these file extensions. (default: js,jsx)
-i, --ignore <items> Folders to ignore. (default: node_modules,__tests__,__mocks__)
-e, --exclude [regexp] Filename pattern to exclude.
-t, --title [value] Document title. (default: React Components)
The options should be added to the corresponding react-doc-creator
script in package.json
.
react-doc-creator src --exclude demo\.jsx
Period (.
) must be escaped since the exclude
option works with RegExp.
react-doc-creator src --ignore tests,utils
Warning: Avoid spaces between directory names.
react-doc-creator src --title 'Project shared components'