Javascript - JsDoc

About

JavaScript Documentation Tool (JSDoc) 1) is a tool that parses inline documentation in JavaScript source files, and produces an documentation of the JavaScript code.

JSDoc is based on javadoc tool that was created for the same purpose for the Java programming language.

Tag

Variable (MemberOf / Full qualified name)

/**
 * @memberOf   myLib
 * or
 * @name       myLib.MyDynamicallyLoadedModule
 */
var MyDynamicallyLoadedModule = {};

Object (Property)

  • Defining the properties of an object
/**
* @var {{value: string,default: string}} value
*/
let value;
/**
 * Test interface
 * @typedef {Object} Type
 * @property {String} tString - I'm a string
 * @property {Boolean} tBoolean - I'm a boolean
 * @property {Number} [tNumber=100] - I'm a number with a default value of 100
 * @property {Function} tFunction - I'm a function
 */

Object as Map

You can also define your object as being a set between a key type and a value type 2)

/**
 * A map-like object that maps arbitrary `string` properties to `number`s.
 *
 * @type {Object.<string, number>}
 */
var stringToNumber;
 
/** @type {Object.<number, object>} */
var arrayLike;

Global Variable

Exactly one line by global as describe below at the top of your file

/* global d3 */
/* global $ */

Function (param, return)

/**
 * @param {Type} someParam
 * @return {undefined} 
 */
function testFunction(someParam) {
  //
}
/**
* @param myParam1
* @param {string=} myParam2 - an optional parameter
* @param {string} [somebody] - Somebody is an optional parameter
*/
function loadDocs(myParam1, myParam2){}

Class (Static, augtments, …

/**
 *  @class MyView
 *  @augments Backbone.View
 *  @static 
*/

fileoverview

example:

/**
 * @fileoverview Search developers.google.com/web for articles tagged
 * "Headless Chrome" and scrape results from the results page.
 */

for

Javascript - For Statement

for (/** @type {MyType} */ const myVar of myArray) {
    // ...
}

Prototype

It should work Unresolved-function-or-method-on-very-basic-JS-class

Library

Type checking with JsDoc and Typescript

JsDoc can be used to type the variable/function

See:

Documentation / Reference





Discover More
Idea Javascript Plugin
IDEA - Javascript Dev

A javascript Project is a Static Web project. You need to define the JavaScript libraries as dependency. The debug session is based on the chrome debug mode. If you choose: locally, Idea will...
Javascript - (Static) Typing (Checker)

in JavaScript. Typing can be added with this method: TypeScript (by Microsoft). in Typescript, Type declaration files express the data types of parameters and functions. - - superset of Javascript...
Javascript - Documentation

How to create code documentation and use it when coding ? - used by Vertx, allow markdown Ndoc...
Javascript - Set

The Set interface represents a set data type and works only with primitive type as there is no way to define an object equality function. object Jsdoc Declaration Add/Delete Size Contains...
Javascript - Typescript

TypeScript is a typed superset of JavaScript that compile to plain JavaScript. It adds static typing. JSdocReference See When...



Share this page:
Follow us:
Task Runner