react-markdown-gen
use react-docgen to extract information from React component, and convert to markdown.
Install
npm install -g react-markdown-gen
Usage:
rmd <component_name> <input_file> [output_file]
example
rmd Calendar index.js readme.md #If no output file exists, markdown string will be printed out. rmd Calendar index.js
For the following component
; /** * General component description. */ { // ... } MyComponentdefaultProps = showPagination: true paginationColor: '#09c' paginationSpace: 20 MyComponentpropTypes = /** Description of prop "children". */ children: ReactPropTypesnodeisRequired showPagination: ReactPropTypesbool paginationColor: ReactPropTypesstring paginationSpace: ReactPropTypesnumber
we are getting this output:
MyComponent
General component description.
Props
Prop | Type | Default | Required | Description |
---|---|---|---|---|
children | node | Yes | Description of prop "children". | |
showPagination | bool | true | No | |
paginationColor | string | '#09c' | No | |
paginationSpace | number | 20 | No |