Giter VIP home page Giter VIP logo

react-docgen-typescript-plugin's Introduction

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

πŸš‡ ⚠️ πŸ’»

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

react-docgen-typescript-plugin's People

Contributors

bebraw avatar hipstersmoothie avatar kherock avatar shilman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.