Site icon LD Talent Blog

Effortless documentation with ESDoc for react components

Effortless documentation with ESDoc for react components.

Effortless documentation with ESDoc for react components.

Hire the author: Abhinav R

Documenting react components manually is time-consuming and difficult to maintain, which often leads to poorly documented projects. ESDoc is a documentation generator for Javascript and can be used readily with our React setup. It relies heavily on documentation tags (@something) to generate a summary of the written code. This summary includes:

Sample conversion from code to doc

This library is extremely easy to use, but it relies on our documentation capabilities as the more exhaustive our documentation for each function, class or file is, the more versatile ESDoc can generate the summaries.

ESDoc doesn’t just generate the documentation summary. It creates a single-point of entry to view and understand the entire repository, including code.

Glossary

  • ESDocs – ESDoc is a good documentation generator for JavaScript official docs here.
  • ReactJS – React is a JavaScript library for building user interfaces
  • Components – Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

How to use ESDoc

Follow the instructions at https://esdoc.org/ to get esdoc installed on your repo. Or, use these commands:
// Installing the library.

$ npm install --save-dev esdoc esdoc-standard-plugin

// Creating the esdoc.json file with config.

$ echo '{
"source": "./src",
"destination": "./docs",
"plugins": [{"name": "esdoc-standard-plugin"}]
}' > .esdoc.json

// Run esdoc to generate documentation

$ ./node_modules/.bin/esdoc

This would generate a summary report at <your-repository>/docs.

The documentation for the repo looks like this. We can traverse through all the functionality such as components, services and collections from the left menu.
An example function documented generated by ESDoc.

Learning Tools

Other features:

GUI-way to view code:

View the actual source code in a structured way

View all functions in one place

View all variables in one place

Coverage

Reflective Analysis:

Conclusions:

If while developing new components dev’s develops a habit to put in proper comments as per ESdocs recommended standards, there is hardly any need to create documentation around new components and ESdocs can generate an exhaustive documentation for you and team to refer from. Also, comments would stay in code as it uses to be. Esdoc just provides an interactive way to access documentation.

If you found this article helpful kindly share it to help others as well. You can find more exciting learning materials here. Cheers!

Citation: Featured image used in this blog is taken from Jory MacKay’s blog on plan.io.

Hire the author: Abhinav R

Exit mobile version