Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Automatically generate documentation for React components using MDX, react-docgen, and GatsbyJS.
Gatsby Documentation Starter is a GatsbyJS template that automatically generates static documentation sites for React component libraries by combining MDX content with props and JSDoc metadata extracted by react-docgen.
It is an open-source documentation starter created by whoisryosuke that pairs GatsbyJS, MDX, and react-docgen to turn React component source code into a static documentation site. It takes component JavaScript files and MDX files as input, parses PropTypes and JSDoc docblocks with react-docgen, and outputs a deployable static site with per-component pages. The starter is designed to be embedded inside existing projects and works by default with the /src/components/ folder.
allComponentMetadata.PropsTable) that renders component props in a table format using the parsed prop metadata.docs subfolder; the component source folder is configurable in gatsby-config.js.gatsby-config.js under siteMetadata.sidebar, while component pages are auto-generated from MDX files; all navigation logic can be overridden in components/sidebar.js.Button.mdx next to Button.js to produce a documentation page at /categoryname/buttonname with an auto-generated props table.gatsby new docs <repo>.gatsby-node.js to create pages from react-docgen data instead of MDX files, or use both together.The starter expects a folder structure where each component has a JavaScript file and a matching MDX file. React-docgen reads JSDoc docblocks and PropTypes from the JS files, and MDX provides additional prose and the page slug (via frontmatter). Gatsby's transformer plugins create GraphQL endpoints (allMdx and allComponentMetadata), and Gatsby builds static pages at /categoryname/pagename.
Pros:
Cons:
gatsby-node.js as described in the README.Yes, it is an open-source starter template, free to use and modify.
Node.js and the Gatsby CLI. You can install it with gatsby new docs https://github.com/whoisryosuke/gatsby-documentation-starter/.
Add a JavaScript file and an MDX file with matching names under the configured source folder (default /src/components/). Set the page name in the JSDoc docblock and the name + menu in the MDX frontmatter.
Yes, clone the repo into a docs subfolder, update the source folder in gatsby-config.js, run npm install and npm run develop.
