Documenting React Components: 5 Open Source Tools You Should Know
source link: https://hackernoon.com/documenting-react-components-5-open-source-tools-you-should-know
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
I m a self learnt Node JS Developer from India.
Introduction
Documenting our code is not the easiest part of the development process, and at times developers even avoid it, saying that it's really boring. In this article, we will take an overview of 5 tools whose purpose is to help us in documenting React components.
mrBean
What is Software Documentation & Why do we need it?
Software documentation is important. Reliable documentation of software applications is a must, and without documentation, our software is incomplete.
When our senior developer stops working for us, it becomes quite difficult for new developers to understand the code without documentation. With the continuous development of our application, sometimes our docs get outdated.
Let’s go through some of the most popular tools that will solve this problem by automating the complete documentation process.
5 Tools for Documenting our React Components
1. DOCZ
React Documentation with Docz
MDX
is? Well, MDX
is something where we can write JSX inside our markdown files.Yeah, you got it right; just think how beautiful this could be. We will be writing our docs in a .mdx file which will be rendered as Documentation by Docz.
React Component Documentation Docz
Playground Component
is a special Component by Docz, which helps to render React Components in docs.Playground Component
creates tables with valuable content describing the React components with live-editable code below the rendered component where we can edit code and test the component efficiently. Brilliant right?
React Documentation Docz
React Component Documentation Props Docz
2. STORYBOOK
StoryBook is an Open Source tool used for User-Interface Development. With StoryBook, we can work on one component at a time and can develop the complete UI without any tech stack. It makes the process of developing UI faster and at the same time increases the scalability and reliability of components by isolating them.
StoryBook React Component Documentation
What is a Story in Storybook?
Well, story in storybook is the single documentation of a component. It renders the UI components. For writing a story for a particular component, we should make a new file with *.stories.js/jsx
the naming convention. If we have a Button component in Button.js
the file, the story for the buttons component will be written in Button.stories.js
. For the storybook, we will be writing docs in CSF
format. Component Story Format, an ES6 Modules-based standard.
Story in Storybook-React Docs
Args in Storybook React Component Documentation
3. REACT STYLEGUIDIST
React Styleguidist Component Documentation
readme
files, source code
, propTypes
declaration.It even displays JSDoc's comment blocks from the Components as Documentation.
import React from 'react'
import PropTypes from 'prop-types'
/**
* General component description in JSDoc format. Markdown is *supported*.
*/
Styleguidist displays props from propTypes declarations in a well-formatted table and looks for Markdown .md
files for documenting. Programming languages used in .md
files in code blocks will be rendered as React Components. It will pick all the files from src/components
directory and if it fails, we can manually configure it in styleguide.config.js
file in the project's root directory.
4. BIT.DEV
Bit dev react component documentation
Bit-dev-component
Bit
with our components by tracking our files using bit add
command. This will add all of our files to the special repository, which is understood by Bit
. We can tag our components in Bit, which makes our components ready for reusable across platforms. It contains all the files, source code, and dependencies of that particular component. Bit auto-generates documentation. If you have any kind of JSDocs or .md in your project, Bit will generate docs from those files.Bit will parses comments from components and render them as component documentation, all we need to do is write those comments in Markdown format. Bit has a special component called Testers that take other components and checks for test files.
If your project has any kind of tests, Testers will run those tests and build components in isolation and helps us to get better stability, reliability of our components for reusability. It handles the complete lifecycle of the component, and we don’t even need to have an extra repo. If we want to use components from bit, we can install them using npm.
For making our components available for other developers, We are supposed to export our components to a scope (a set of components), Once we export our Component to Scope, It will be available for all the developers. Bit has a live-editable playground where we can test our rendered components.
Bit-dev Playground react documentation
5. REACT DOCGEN
Docgen is a CLI-based tool used for documenting React components. It is a simple Documentation tool that generates documentation from the React components. Docgen uses ast-types
and @babel/parser
to parse the source code, and with the help of methods, it extracts information from the source code into JSON blob or JavaScript object.
It looks for components that are defined via React.createClass
. We can customize the extraction process by using and manipulating the API. React-Docgen looks for Babel configuration for use, and if there is no such file, it will follow the default configuration.
Conclusion
From Docz to Bit, I’ve covered the most popular tools used for React Components documentation. These tools improve the quality of components with the help of their super-rich features and make sure we are not wasting our time building and maintaining custom documentation sites.
Thanks for reading! Peace, bubbyeye, and yeah never share your food!!
Mr bean doesn't share his food
Connect with me
Also published here.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK