Skip to main content

Command-line arguments to JSDoc

At its most basic level, JSDoc is used like so:

/path/to/jsdoc yourSourceCodeFile.js anotherSourceCodeFile.js ...

where ... are paths to other files to generate documentation for.

Additionally, one may provide the path to a Markdown file (ending in ".md") or a file named "README", and this will be added to the documentation on the front page. See these instructions.

JSDoc supports a number of command-line options, many of which have both long and short forms. Alternatively, the command-line options may be specified in a configuration file given to JSDoc. The command-line options are:

OptionDescription
-a <value>, --access <value>Only display symbols with the given access property: private, protected, public, or undefined, or all for all access levels. By default, all except private symbols are shown.
-c <value>, --configure <value>The path to a JSDoc configuration file. Defaults to conf.json or conf.json.EXAMPLE in the directory where JSDoc is installed.
--debugLog information that can help debug issues in JSDoc itself.
-e <value>, --encoding <value>Assume this encoding when reading all source files. Defaults to utf8.
-h, --helpDisplay information about JSDoc's command-line options, then exit.
--match <value>Only run tests whose names contain value.
--nocolorWhen running tests, do not use color in the console output. On Windows, this option is enabled by default.
-p, --privateInclude symbols marked with the @private tag in the generated documentation. By default, private symbols are not included.
-P, --packageThe package.json file that contains the project name, version, and other details. Defaults to the first package.json file found in the source paths.
--pedanticTreat errors as fatal errors, and treat warnings as errors. Defaults to false.
-q <value>, --query <value>A query string to parse and store in the global variable env.opts.query. Example: foo=bar&baz=true.
-r, --recurseRecurse into subdirectories when scanning for source files and tutorials.
-R, --readmeThe README.md file to include in the generated documentation. Defaults to the first README.md file found in the source paths.
-t <value>, --template <value>The path to the template to use for generating output. Defaults to templates/default, JSDoc's built-in default template.
-T, --testRun JSDoc's test suite, and print the results to the console.
-u <value>, --tutorials <value>Directory in which JSDoc should search for tutorials. If omitted, no tutorial pages will be generated. See the tutorial instructions for more information.
-v, --versionDisplays JSDoc's version number, then exits.
--verboseLog detailed information to the console as JSDoc runs. Defaults to false.
-X, --explainDump all doclets to the console in JSON format, then exit.

Examples

Generate documentation for files in the ./src directory, using the configuration file /path/to/my/conf.json, and save the output in the ./docs directory:

/path/to/jsdoc src -r -c /path/to/my/conf.json -d docs

Run all JSDoc tests whose names include the word tag, and log information about each test:

/path/to/jsdoc -T --match tag --verbose

Configuring JSDoc with a configuration file