React encourages you to build modular applications with components. Modularity brings all sorts of advantages, including improved reusability. But, when you aim to share and reuse a component, you better make sure it is easy to discover, understand and put to use. You need to document components.
Today, modern tools can help automate some of the documentation workflows and to turn the consumption of component documentation into a rich, visual and even interactive experience. Some tools even combine such docs as an integral part of the very workflow of sharing components.
To achieve beautiful component documentation without working too hard, I’ve gathered some of the best and most popular tools for documenting React components. Feel free to comment and add your own ideas and tools.
The platform for shared components.
Bit more than just a documentation tool for components. It’s an open-source tool that lets you encapsulate components with all their files and dependencies, and run them across different applications out-of-the-box.
The bit.dev platform lets you share and collaborate on components across your applications. All your shared components are made discoverable for your team to find and use in their projects and easily share their own components.
The components you share to bit.dev become discoverable in your team’s a shared component hub. You can search for components by context, bundle-size or even dependencies. You can quickly browse results based on visual snapshots of the actually-rendered components, and choose with your eyes.
When you go into one of your component’s web-page, you will discover that Bit presents the component in a live playground so that you can play with it before choosing to consume it in your application. If you have JSDocs or an .md file as part of the code, Bit will parse and present these docs as well. If the components include unit-test files, Bit will run them in isolation and present the results as part of the documentation for every component.
When found a component you like to use, just use NPM or Yarn to install it. You can even use Bit to develop and update the components directly from any consuming application, so your team can collaborate and build together.
When sharing components through Bit you don’t have to set up any more repositories or tools, no need to refactor or change your code, and the same hub where you share components are where they become documented and discoverable, pretty much out of the box.
StoryBook and StyleGuidist are too wonderful projects that help develop components in isolation while visually rendering and documenting them.
StoryBook* *is a development environment for UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components. When building a library, StoryBook is a neat way to visualize and document components and different AddOns make it easier to integrate into your different tools and workflows. You can even reuse stories in unit-tests to confirm nuanced functionality.
StyleGuidist is an Isolated React component development environment with a living style guide. It provides a hot reloaded dev server and a living style guide that lists component propTypes and shows editable usage examples based on .md files. It supports ES6, Flow and TypeScript and works with Create React App out of the box. The auto-generated usage docs can help Styleguidist function as a documentation portal for your team’s different components.
Component playgrounds are a neat way to play with components and learn how they work. When you can combine them as part of your documentation (or as part of your shared-components workflow), playgrounds help you quickly learn how code works and decide if you want to use the component.
Codesandbox is an online editor for quickly creating and playing-with small projects like components. After creating something interesting you can show it to others by just sharing the url. CodeSandbox features a live preview to show the result of the code while you’re typing and has extensions built to integrate into your different tools and your development workflow.
Stackblitz is an “online IDE for web applications” powered by Visual Studio Code. Much like Codesnadbox, StackBlitz is an online IDE where you can create Angular & React projects that are made shareable via a URL link. Like Codesandbox, it automatically takes care of installing dependencies, compiling, bundling, and hot reloading as you type. Take a look.
Docz makes it easier to build Gtabsy-powered documentation websites for your code. It’s based on MDX (*Markdown + JSX) *to leverage markdown for component documentation. Basically, you can write an .mdx file anywhere in your project and Docz will streamline the process of turning it into a documentation portal of your own design deployed to Netlify. Useful right?
*✍🏻It has never been so easy to document your things! - pedronauck/docz*github.com
MDX-docs lets you document and develop React components with MDX and Next.js. You can mix markdown with inline JSX to render React components. Write markdown as you normally would and use ES import syntax to use custom components in your document. Built-in components render JSX fenced code blocks as live previews with editable code, powered by react-live.
*A CLI and toolbox to extract information from React component files for documentation generation purposes. …*github.com