Skip to content

Easily integrate react-docgen with docusaurus 2

License

Notifications You must be signed in to change notification settings

atomicpages/docusaurus-plugin-react-docgen

Repository files navigation

Docusaurus Plugin react-docgen

A Docusaurus 2.x plugin that help generate and consume auto-generated docs from react-docgen.

Installation

Grab from NPM and install along with react-docgen:

npm i docusaurus-plugin-react-docgen react-docgen # or
yarn add docusaurus-plugin-react-docgen react-docgen

Usage

Inside your docusaurus.config.js add to the plugins field and configure with the src option with full glob support 👍

module.exports = {
  plugins: [
    [
      'docusaurus-plugin-react-docgen',
      {
        // pass in a single string or an array of strings
        src: ['path/to/**/*.tsx', '!path/to/**/*test.*'],
        route: {
          path: '/docs/api',
          component: require.resolve('./src/components/MyDataHandler.js'),
          exact: true,
        },
      },
    ],
  ],
};

Any pattern supported by fast-glob is allowed here (including negations)

Options

Name Type Required Description
src string | string[] Yes Tell react-docgen where to ook for source files. Use relative, absolute, and/or globbing syntax
global boolean No Store results so they're globally accessible in docusaurus
route RouteConfig No Makes docgen results accessible at the specified URL. Note modules cannot be overridden.
docgen docgen config No Pass custom resolvers and handlers to react-docgen
parserOptions babel parser options No Pass custom options to @babel/parser
babel docgen options No Pass specific options to @babel/parse that aids in resolving the correct babel config file