Skip to main content

Why API Documentation required on JS?



JavaScript Doc is the de facto standard for documenting JavaScript code. During my development period, I have worked with more than 50’s of JavaScript Libraries; after dealing with so many documentation, I found a lot of issues with JavaScript documentation. As lagging behind Good documentation, development time increases. A good documentation will decrease development time and it makes the developers life easy. It is very simple and easy to integrate with the system. Whatever the reason, not documenting an application is never a good thing, even if it is usually something of a chore.


This documentation will help you to understand the project and its flow, without looking into the actual code in very less time. All the entities described in document will also give link to the code of that particular entity. Let’s have a look for some of the commonly used annotations enlisted below:
Sr. No.
Annotation
Description
               1. 
@constructor
Marks the functions as the constructor.
         2.        
@function
To show a function or method, locally or globally.
         3.        
@param
To show the parameter of a function.
         4.        
@extends/@implements
To indicate the implementing interface or extending class of current class.
         5.        
@returns
Used to enlist return value from a function.
         6.        
@namespace
Shows that an object creating a namespace for its members.
         7.        
@type/@var
To show the member or it’s type.
         8.        
@memberOf
To show the parent of the member.

JSDoc is like an API documentation processor for the JavaScript. As a tool, JSDoc takes JavaScript code with special /** */ comments and produces HTML documentation for it. For example: Given the following code.



                     











The generated HTML looks as follows in a web browser:

                




Documentation is still scarce, but I hope this post help you how to run JavaScript Doc and how its syntax works, also very helpful in decreasing development time.

Comments