Documenting JavaScript APIs with JSDoc¶
When to use @func¶
By default, the jsdoc documents all the exported members by
export.functionName
. To document them as static members of a namespace,
you use @func <functionName>. For methods and constants are defined
without export, you don’t need to use @func <functionName>. Note: The
behavior in namespace is opposite to module.
When to use @memberof¶
For methods or constants, you have to use @memberof <namespace> to group them under the <namespace>. Without @memberof tag, all the methods and constants will appear under the global category.
Known issues:¶
There is more than one way to produce the same output using the tags.
Depending on the templates, the tags may not work exactly as they are described. The default template came with JSDoc is located in the jsdoc directory
Note: the following two tags worked for minami template. But the docstrap template seems not recognizing them correctly.
@private
The @private tag marks a symbol as private, or not meant for general use. Private members are not shown in the generated output unless JSDoc is run with the -a/–private command-line option or specifying the option in the configuration. The @private tag is equivalent to @access private.
@public
The @public tag indicates that a symbol should be documented as if it were public. By default, JSDoc treats all symbols as public, so using this tag does not normally affect the generated documentation. However, you may prefer to use the @public tag explicitly so it is clear to others that you intended to make the symbol public. However, @public does not change the symbol’s scope. The @public tag is the same as @access public.
Start from scratch:¶
Add the dependent libraries to package.json
"eslint-plugin-jsx-a11y": "^0.6.2", "jsdoc-jsx": "^0.1.0", "ink-docstrap": "^1.2.1"
Build your libraries, for example,
gradle :firefly:war gradle :firefly:deploy
Use jsdoc_config.json located in firefly/src/firefly directory or create your own configuration file.
Add proper tags in each source file.
JSDoc comments should generally be placed immediately before the code being documented. It must start with a /** sequence in order to be recognized by the JSDoc parser.
Generate the javascript documentation at /hydra/cm/firefly directory by running:
./node_modules/.bin/jsdoc –c path/to/your-configuration-file
(Note. Use any command line options to override the options defined in the configuration file.)
To check the available command line options:
./node_modules/.bin/jsdoc -h