Using Directives

Using automodule

Document nested elements from a module represented by a file or a index.js file within a folder:

example/
 |- index.js
 `- test.js

Two modules are available in the example above: example and example.test

.. js:automodule:: example

The available options are:

  • members:
    This option can be boolean if no arguments are given to indicate that all members should be documented, or a white list of member names to display.
  • skip-description:
    Indicate whether the module description should be skipped.
  • skip-data-value:
    Indicate whether data values within the module should be skipped.
  • skip-attribute-value:
    Indicate whether attribute values within the module should be skipped.
  • undoc-members:
    Indicate whether members with no docstrings should be displayed.
  • private-members:
    Indicate whether private members (with a name starting with an underscore) should be displayed.
  • module-alias:
    String element to replace the module name.
  • module-path-alias:
    String element to replace the module path.
  • force-partial-import:
    Indicate whether each import statement display within the module should be indicated with partial import.

Using autodata

Document a variable declaration using one of the following way:

Example:

/** PI Mathematical Constant. */
const PI = 3.14159265359;
.. js:autodata:: example.PI

The available options are:

  • alias:
    String element to replace the data name.
  • module-alias:
    String element to replace the module name.
  • module-path-alias:
    String element to replace the module path.
  • force-partial-import:
    Indicate whether the data import statement display should be indicated with partial import if the data element is exported.
  • skip-value:
    Indicate whether data value should be skipped.

Using autofunction

Document a function declaration using one of the following way:

Example:

/**
 * Return a distance converted from Meter to Miles.
 *
 * :param d: integer
 * :return: integer
 */
const toMiles = (d) => {
    return d * 0.00062137;
}
.. js:autofunction:: example.toMiles

The available options are:

  • alias:
    String element to replace the function name.
  • module-alias:
    String element to replace the module name.
  • module-path-alias:
    String element to replace the module path.
  • force-partial-import:
    Indicate whether the function import statement display should be indicated with partial import if the function element is exported.

Warning

These function declaration statements are not supported at the moment:

Using autoclass

Document a class declaration using one of the following way:

Example:

/*
 * A Square class declaration.
 */
class Square extends Polygon {

    /** Square ID. */
    static name = 'Square';

    /** Construct the Square object. */
    constructor(length) {
        super(length, length);
    }

    /**
     * Compute and get the area from the square.
     *
     * :return: double
     */
    get area() {
        return this.height * this.width;
    }

    /**
     * Indicate whether a polygon is a square.
     *
     * :param polygon: :class:`Polygon` object
     * :return: boolean
     */
    static isSquare(polygon) {
        return (polygon.height === polygon.width);
    }
}
.. js:autoclass:: example.Square

The available options are:

  • members:
    This option can be boolean if no arguments are given to indicate that all members should be documented, or a white list of member names to display.
  • skip-constructor:
    Indicate whether the constructor method should be displayed if available.
  • skip-attribute-value:
    Indicate whether attribute values within the class should be skipped.
  • undoc-members:
    Indicate whether members with no docstrings should be displayed.
  • private-members:
    Indicate whether private members (with a name starting with an underscore) should be displayed.
  • alias:
    String element to replace the class name.
  • module-alias:
    String element to replace the module name.
  • module-path-alias:
    String element to replace the module path.
  • force-partial-import:
    Indicate whether the class import statement display should be indicated with partial import if the class element is exported.

Warning

The documentation of nested elements within a variable is not supported

Example:

var Rectangle = {
    constructor(height, width) {
        this.height = height;
        this.width = width;
    }
};

Using automethod

Document a method using one of the following way:

Example:

From the class example above, the static method isSquare would be documented as follow:

.. js:automethod:: example.Square.isSquare

Warning

These method declaration statements are not supported at the moment:

Using autoattribute

Document a class attribute using one of the following way:

Example:

From the class example above, the static attribute name would be documented as follow:

.. js:autoattribute:: example.Square.name

The available options are:

  • skip-value:
    Indicate whether attribute value should be skipped.