1.0.6 • Published 24 days ago

react-docgen-typescript-plugin v1.0.6

Weekly downloads
1,214,531
License
MIT
Repository
github
Last release
24 days ago

Install

npm install --save-dev react-docgen-typescript-plugin
# or
yarn add -D react-docgen-typescript-plugin

Usage

NOTE: The TypeScript compiler options allowSyntheticDefaultImports and esModuleInterop will make react-docgen-typescript-plugin a lot harder! Turn them off for faster build times.

const ts = require('typescript');
const ReactDocgenTypescriptPlugin = require("react-docgen-typescript-plugin").default;

module.exports = {
  plugins: [
    // Will default to loading your root tsconfig.json
    new ReactDocgenTypescriptPlugin(),
    // or with a specific tsconfig
    new ReactDocgenTypescriptPlugin({ tsconfigPath: "./tsconfig.dev.json" }),
    // or with compiler options
    new ReactDocgenTypescriptPlugin({ compilerOptions: { jsx: ts.JsxEmit.Preserve } }),
  ],
};

Options

This plugins support all parser options from react-docgen-typescript and all of the following options

OptionTypeDescriptionDefault
tsconfigPathstringSpecify the location of the tsconfig.json to use.null
compilerOptionsobjectSpecify compiler options. Cannot be used with tsconfigPathnull
docgenCollectionNamestring or nullSpecify the docgen collection name to use. All docgen information will be collected into this global object. Set to null to disable.STORYBOOK_REACT_CLASSES
setDisplayNamebooleanSet the components' display name. If you want to set display names yourself or are using another plugin to do this, you should disable this option.true
typePropNamestringSpecify the name of the property for docgen info prop type.type
excludeglob[]Glob patterns to ignore and not generate docgen information for. (Great for ignoring large icon libraries)[]
includeglob[]Glob patterns to generate docgen information for['**/**.tsx']

Debugging

If you want to see how this plugins is including and excluding modules set the DEBUG environment variable.

  • DEBUG=docgen:* - All logs
  • DEBUG=docgen:include - Included modules
  • DEBUG=docgen:exclude - Excluded modules
  • DEBUG=docgen:docs - Generated docs
DEBUG=docgen:* npm run storybook

Another great way of debugging your generated docs is to use a debugger statement in your component source file. If you turn off source maps you will be able to see the code that this package generates.

Prior Art

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

1.0.6

24 days ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

4 years ago

0.5.2

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago