Skip to content
Latchkey

jsdoc -c: Generate JavaScript API Docs

jsdoc -c jsdoc.json runs JSDoc with a configuration file, generating an HTML API reference from /** ... */ comments.

JSDoc parses tagged comments in plain JavaScript. Most projects drive it with a config file (-c) that lists sources, plugins, and the output template.

What it does

jsdoc scans the given source files, parses their JSDoc comments and code structure, and writes an HTML site to the destination directory (default out/). A config file passed with -c centralizes source globs, the template, and plugins like markdown support.

Common usage

Terminal
jsdoc -c jsdoc.json
# document a directory recursively into a chosen folder
jsdoc -r src -d docs/api
# include a README as the landing page
jsdoc -c jsdoc.json -R README.md

Options

FlagWhat it does
-c <file>Path to the JSDoc configuration file
-d <dir>Output directory (default out/)
-rRecurse into subdirectories
-R <file>Use a markdown file as the home page
-t <dir>Use a specific output template
-P <file>Read metadata from a package.json

In CI

Keep the config file in the repo and call jsdoc -c jsdoc.json so the build is reproducible. JSDoc itself rarely fails on undocumented code, so pair it with a linter (eslint-plugin-jsdoc) if you want to enforce completeness. Cache node_modules; regenerate the docs each run.

Common errors in CI

ERROR: Unable to find the source file or directory ... means a path in the config or on the CLI is wrong. ERROR: Unable to parse a tag's type expression for source file ... points at a malformed @type {...} in a comment. There are no input files to process. means the source.include globs matched nothing.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →