JSDoc is a markup language for adding inline API documentation to JavaScript source code. This is distinct from the various tools that parse and manipulate code that follows the JSDoc syntax.
The JSDoc markup language is similar to the Javadoc syntax, used for documenting Java code, but is specialized to work with JavaScript's more dynamic syntax and therefore unique, as it is not completely compatible with Javadoc. However, like Javadoc, JSDoc allows the programmer to create doclets and tags which can then be translated into published output, like HTML or RTF.
Example:
/**
Represents a book.
@constructor
@param {string} title - The title of the book.
@param {string} author - The author of the book.
*/
function Book(title, author) {
}
The following annotations are commonly used in modern JSDoc, but the full list varies between implementations:
@paramDocuments a method parameter; a datatype indicator can be added between curly braces@returnDocuments a return value@constructorMarks a function as a constructor@deprecatedMarks a method as deprecated@privateSignifies that a method is private@requiresDescribe a required resource.@thisSpecifies the type of the object to which the keyword "this" refers within a function.@throwsDocuments an exception thrown by a method@exceptionSynonym for @throws@authorDeveloper's name@versionProvides the version number of a library