This is a fork of react-doc-generator to provide additional features for asciidoc or custom templates.
Generate simple React components documentation in either
$ npm install -save-dev react-asciidoc-generator
Check every option running react-asciidoc-generator
with --help
or -h
:
$ react-asciidoc-generator --help
Usage: react-asciidoc-generator <dir> [options]
Options:
-h, --help output usage information
-V, --version output the version number
-x, --extensions <items> Include only these file extensions. Default: js,jsx
-f, --format <format> Output format (asciiddoc|asciidoc) [asciidoc]
-i, --ignore <items> Folders to ignore. Default: node_modules,__tests__,__mocks__
-e, --exclude-patterns <items> Filename patterns to exclude (may be comma-separated list of regexp). Default: '.*\.spec.(jsx|js)'
-t, --title [value]> Document title. Default: 'Components'
-o, --output <file> Output file to write. Default (asciidoc): 'DOCUMENTATION.ADOC'. Default (markdown): 'DOCUMENTATION.MD'
--handlebar-template [path] Custom handlebar output template. Alternative to --format.
Example:
`$ react-asciidoc-generator src -o DOCUMENTATION.adoc
Example:
In your package.json
put:
{
// ...
"scripts": {
"doc": "react-asciidoc-generator ./app/components/custom -o DOCUMENTATION.ADOC"
}
// ...
}
so then you are able to call this script by the command line:
$ npm run doc
/**
* General component description.
* You can even use the native Markdown here.
* E.g.:
* ```html
* <MyComponent foo={541} />
* ```
*/
export class MyComponent extends React.Component {
static displayName = 'Official Component Name'
static propTypes = {
/**
* Description of prop "foo".
*/
foo: React.PropTypes.number,
/**
* Description of prop "bar" (a custom validation function).
*/
bar: function(props, propName, componentName) {
// ...
},
baz: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.string
]),
}
static defaultProps = {
foo: 10000099999
}
render () {
return (<div>Hello</div>);
}
}
Because react-asciidoc-generator uses react-docgen library, you can follow other examples here.
This is an example of what you'll see in your terminal.
Forked from original module 'react-doc-generator' by Marcin Borowski (https://github.com/marborkowski/react-doc-generator)
MIT License
Copyright (c) 2017 Marcin Borkowski ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.