Skip to main content
The generate command is the primary command for generating API documentation. It processes markdown files from the Node.js repository and outputs documentation in various formats.

Usage

doc-kit generate [options]

Global Options

These options apply to the entire doc-kit CLI, not just the generate command.
--log-level
string
Set the logging verbosity level. Controls how much diagnostic information is printed during execution.Choices: debug, info, warn, error, fatalDefault: infoExample: --log-level debug

Command Options

--config-file
string
Path to a configuration file. When provided, the configuration file will be loaded and merged with CLI options and defaults.
-i, --input
string[]
Input file patterns using glob syntax. Specify one or more glob patterns to match the markdown files you want to process.Example: -i "path/to/node/doc/api/*.md"
-t, --target
string[]
Target generator(s) to use for output. You can specify multiple generators to produce different output formats simultaneously.Available generators:
  • json-simple - Simple JSON output
  • legacy-html - Legacy HTML format (1:1 match with Node.js legacy tooling)
  • legacy-html-all - Legacy HTML all-in-one format
  • man-page - Man page format
  • legacy-json - Legacy JSON format
  • legacy-json-all - Legacy JSON all-in-one format
  • addon-verify - Addon verification
  • api-links - API links generator
  • orama-db - Orama database for search functionality
  • llms-txt - LLMs.txt format
  • sitemap - Sitemap generator
  • web - Redesigned web pages
--ignore
string[]
File patterns to ignore during processing. Uses glob syntax to exclude files.Example: --ignore "**/internal/**" "**/*.test.md"
-o, --output
string
The output directory where generated documentation will be written.Example: -o out or -o dist/docs
-p, --threads
number
Number of threads to use for parallel processing. Must be at least 1.Default: Number of CPU cores available (automatically detected)
--chunk-size
number
Number of items to process per worker thread. Must be at least 1.Default: 10
-v, --version
string
Target Node.js version in semver format. This is used for version-specific documentation generation.Default: Current Node.js version (e.g., v22.14.0)
-c, --changelog
string
Changelog URL or local file path. Used to incorporate changelog information into the generated documentation.Default: https://raw.githubusercontent.com/nodejs/node/HEAD/CHANGELOG.md
--git-ref
string
Git ref URL for linking to source code. This creates links to the specific commit or branch in the repository.Default: https://github.com/nodejs/node/tree/HEAD
--index
string
URL or path to the index.md file. This file typically contains the main documentation index.Example: --index path/to/node/doc/api/index.md
--minify
boolean
Enable minification of output files.Default: true
--type-map
string
URL or path to a type map file for type reference mapping.

Examples

Legacy HTML and JSON Output

To generate a 1:1 match with the legacy Node.js documentation tooling:
npx doc-kit generate \
  -t legacy-html \
  -t legacy-json \
  -i "path/to/node/doc/api/*.md" \
  -o out \
  --index path/to/node/doc/api/index.md
Output:
Generating documentation...
✓ Processed 50 files
✓ Generated legacy-html output
✓ Generated legacy-json output
✓ Output written to out/

Redesigned Web Documentation

To generate the redesigned documentation pages with search functionality:
npx doc-kit generate \
  -t web \
  -t orama-db \
  -i "path/to/node/doc/api/*.md" \
  -o out \
  --index path/to/node/doc/api/index.md
To use the search functionality, you must serve the output directory:
npx serve out

Multiple Generators

Generate multiple output formats simultaneously:
npx doc-kit generate \
  -t legacy-html \
  -t legacy-json \
  -t man-page \
  -t web \
  -i "path/to/node/doc/api/*.md" \
  -o out

Custom Configuration

Specify custom settings for version, changelog, and threading:
npx doc-kit generate \
  -t web \
  -i "path/to/node/doc/api/*.md" \
  -o dist/docs \
  -v v20.0.0 \
  -p 8 \
  --chunk-size 20 \
  --git-ref https://github.com/nodejs/node/tree/v20.0.0

Using a Configuration File

Use a configuration file to manage complex settings:
npx doc-kit generate --config-file ./doc-kit.config.mjs

Performance Tips

The --threads option controls parallel processing. By default, it uses all available CPU cores. For optimal performance:
  • Use fewer threads on machines with limited memory
  • Increase --chunk-size when processing many small files
  • Decrease --chunk-size when processing large files
When using multiple generators, they run in parallel. The total processing time is roughly equivalent to the slowest generator.
Minification is enabled by default. Disable it with --minify false during development to improve readability of output files.

Additional Resources

  • Configuration - Learn about configuration files and options
  • Generators - Explore available generators and create custom ones

Build docs developers (and LLMs) love