|
1 |
| -# My Typescript Template |
| 1 | +# Docusaurus Plugin `react-docgen-typescript` |
2 | 2 |
|
3 |
| -A small template that I use to build node typescript-based projects. |
| 3 | +A Docusaurus 2.x plugin that help generate and consume auto-generated docs from `react-docgen-typescript`. |
4 | 4 |
|
5 |
| -## Stack |
| 5 | +## Installation |
6 | 6 |
|
7 |
| -* `typescript` |
8 |
| -* `@pika/pack` |
9 |
| -* `eslint` |
10 |
| -* `prettier` |
| 7 | +Grab from NPM and install along with `react-docgen-typescript`: |
| 8 | + |
| 9 | +```sh |
| 10 | +npm i docusaurus-plugin-react-docgen-typescript react-docgen-typescript # or |
| 11 | +yarn add docusaurus-plugin-react-docgen-typescript react-docgen-typescript |
| 12 | +``` |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +Inside your `docusaurus.config.js` add to the `plugins` field and configure with the `src` option with full glob support :+1:. |
| 17 | + |
| 18 | +```js |
| 19 | +module.exports = { |
| 20 | + // ... |
| 21 | + plugins: [ |
| 22 | + [ |
| 23 | + 'docusaurus-plugin-react-docgen-typescript', |
| 24 | + { |
| 25 | + // pass in a single string or an array of strings |
| 26 | + src: ['path/to/**/*.tsx', '!path/to/**/*test.*'], |
| 27 | + global: true, |
| 28 | + parserOptions: { |
| 29 | + propFilter: (prop, component) => { |
| 30 | + if (prop.parent) { |
| 31 | + return !prop.parent.fileName.includes('@types/react'); |
| 32 | + } |
| 33 | + |
| 34 | + return true; |
| 35 | + }, |
| 36 | + }, |
| 37 | + }, |
| 38 | + ], |
| 39 | + ], |
| 40 | +}; |
| 41 | +``` |
| 42 | + |
| 43 | +Any pattern supported by [`fast-glob`](https://github.com/mrmlnc/fast-glob) is allowed here (including negations). |
| 44 | + |
| 45 | +## Options |
| 46 | + |
| 47 | +| Name | Type | Required | Description | |
| 48 | +| ----------------- | ---------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 49 | +| `src` | `string` \| `string[]` | Yes | Tell `react-docgen` where to look for source files. | |
| 50 | +| `global` | `boolean` | No | Store results so they're [globally accessible](https://v2.docusaurus.io/docs/docusaurus-core#useplugindatapluginname-string-pluginid-string) in docusaurus | |
| 51 | +| `route` | [`RouteConfig`](https://v2.docusaurus.io/docs/lifecycle-apis#actions) | No | Makes docgen results accessible at the specified URL. Note `modules` cannot be overridden. | |
| 52 | +| `tsConfig` | `string` | No | Specify the path to your custom tsconfig file (note that in most cases the default config is sufficient) | |
| 53 | +| `compilerOptions` | `CompilerOptions` | No | Pass custom ts compiler options in lieu of of a custom `tsConfig` | |
| 54 | +| `parserOptions` | [`ParserOptions`](https://github.com/styleguidist/react-docgen-typescript#options) | No | Options passed to `react-docgen-typescript` | |
0 commit comments