DEV Community

allnulled
allnulled

Posted on

Document APIs with Javadoc: from comments to README, in a nut!

Documenting code is usually needed for others to understand what we do.

I created, time ago, javadoc, an npm module to fastly generate json/markdown from any source code file, from a comfortable command line interface.

Personally, I document all my projects with it, and you can do it as well.

This is how I exploit this tool.

1. Install

$ npm i -g javadoc

2. Comment your code

This can be done with any programming language.

/**
 * 
 * #### `myFunction(variable:Type):TypeReturned`
 * 
 * @name myFunction
 * @parameter
 * @parameter - `variable:Type` Description
 * @return `TypeReturned`
 * @description Description
 * 
 */

This comment will become fresh Markdown code that we can insert in the README.md file of our project, directly.

3. Generate documentation

To generate a markdown file with all our comments, we run in the console:

$ javadoc
  --include filesOne/**/*.js
  --format markdown
  --output README.md

Gotcha!!!

Your project was documented successfully.

Happy documenting!!!

Top comments (0)