Package detail

@storybook/react-docgen-typescript-plugin

hipstersmoothie16.7mMIT1.0.1

A webpack plugin to inject react typescript docgen information.

react, docgen, typescript, webpack

readme

react-docgen-typescript-plugin

A webpack plugin to inject react typescript docgen information

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

Option Type Description Default
tsconfigPath string Specify the location of the tsconfig.json to use. null
compilerOptions object Specify compiler options. Cannot be used with tsconfigPath null
docgenCollectionName string or null Specify the docgen collection name to use. All docgen information will be collected into this global object. Set to null to disable. STORYBOOK_REACT_CLASSES
setDisplayName boolean Set 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
typePropName string Specify the name of the property for docgen info prop type. type
exclude glob[] Glob patterns to ignore and not generate docgen information for. (Great for ignoring large icon libraries) []
include glob[] 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):


Andrew Lisowski

💻 🎨 📖 🤔 🚧 🚇 ⚠️

Michael Shilman

💻

Kyle Herock

💻

Juho Vepsäläinen

🚇 ⚠️ 💻 📖

Egor Pogadaev

⚠️ 💻

Anton Savoskin

💻

Trevor Burnham

⚠️ 💻

Maxime Meriouma-Caron

🚇 ⚠️ 💻

Adam Skoufis

💻

Nicholas Narsing

📖 ⚠️ 💻

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

changelog

v1.0.0 (Sat Jun 05 2021)

💥 Breaking Change

Authors: 2


v0.7.1 (Tue May 11 2021)

:tada: This release contains work from a new contributor! :tada:

Thank you, Kyle Herock (@kherock), for all your work!

🐛 Bug Fix

Authors: 1


v0.7.0 (Fri Dec 04 2020)

🚀 Enhancement

Authors: 1


v0.6.3 (Thu Dec 03 2020)

🐛 Bug Fix

🏠 Internal

Authors: 1


v0.6.2 (Fri Nov 06 2020)

🐛 Bug Fix

Authors: 1


v0.6.1 (Fri Nov 06 2020)

🐛 Bug Fix

Authors: 1


v0.6.0 (Thu Aug 13 2020)

🚀 Enhancement

Authors: 1


v0.5.2 (Thu Jul 23 2020)

🐛 Bug Fix

Authors: 1


v0.5.1 (Tue Jun 16 2020)

🐛 Bug Fix

Authors: 1


v0.5.0 (Tue Jun 16 2020)

🚀 Enhancement

  • default to loading root tsconfig.json when no typescript configuration is provided #9 (@hipstersmoothie)

Authors: 1


v0.4.1 (Mon Jun 15 2020)

🐛 Bug Fix

📝 Documentation

Authors: 1


v0.4.0 (Fri Jun 12 2020)

🚀 Enhancement

📝 Documentation

Authors: 1


v0.3.0 (Fri Jun 12 2020)

🚀 Enhancement

Authors: 1


v0.2.0 (Fri Jun 12 2020)

Release Notes

From #3

New options:

  • include - Glob patterns to generate docs for
  • exclude - Glob patterns to ignore doc generation. Great for ignoring all of your Icons

🚀 Enhancement

📝 Documentation

Authors: 1


v0.1.0 (Wed Jun 10 2020)

🚀 Enhancement

  • allow for compilerOption, get features in parity with react-docgen-typescript-loader #1 (@hipstersmoothie)

Authors: 1


v0.0.2 (Tue Jun 09 2020)

⚠️ Pushed to master

Authors: 1


v0.0.1 (Tue Jun 09 2020)

⚠️ Pushed to master

Authors: 1