|
1 | 1 | # react-ts-docgen
|
| 2 | + |
| 3 | +A tiny CLI wrapper around [react-docgen-typescript](https://github.com/styleguidist/react-docgen-typescript). |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm i react-docgen-typescript @types/react react-ts-docgen typescript --save-dev |
| 9 | + |
| 10 | +# yarn |
| 11 | +yarn add react-docgen-typescript @types/react react-ts-docgen typescript --dev |
| 12 | +``` |
| 13 | + |
| 14 | +`react-docgen-typescript`, `@types/react`, and `typescript` are all **peer dependencies** of this packae. |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +The main intended usage of this module is via CLI. |
| 19 | + |
| 20 | +```bash |
| 21 | +# See the help docs |
| 22 | +npx react-ts-docgen --help |
| 23 | + |
| 24 | +# Glob patterns are supported |
| 25 | +# Write each file out to a directory with -d, or --out-dir |
| 26 | +npx react-ts-docgen ./src/**/* -d ./out |
| 27 | + |
| 28 | +# Filter extensions with -x |
| 29 | +npx react-ts-docgen ./src/**/* -x tsx -d ./out |
| 30 | + |
| 31 | +# Full globbing goodness is supported |
| 32 | +npx react-ts-docgen ./src/**/*.{ts,tsx} |
| 33 | + |
| 34 | +# Concat all doclets into a single file |
| 35 | +npx react-ts-docgen ./src/**/* -o ./out/doclet/files.json |
| 36 | +``` |
| 37 | + |
| 38 | +Any custom options that you want to pass to `react-docgen-typescript` can be done through options: |
| 39 | + |
| 40 | +```bash |
| 41 | + --config Path to your tsconfig.json. By default the |
| 42 | + script will look in the current working |
| 43 | + directory to find the tsconfig [string] |
| 44 | + --skip-props-without-doc Skip props without doc |
| 45 | + [boolean] [default: true] |
| 46 | + --skip-props-with-name Skip the specified list of props without |
| 47 | + doc [array] |
| 48 | + --skip-components-with-name Skip the [array] |
| 49 | + --extract-literal-values-from-enum Convert enums and unions to docgen enum |
| 50 | + format [boolean] [default: false] |
| 51 | + --save-value-as-string Save default value props as strings |
| 52 | + regardless of type |
| 53 | + [boolean] [default: false] |
| 54 | +``` |
0 commit comments