On this page

The command-line interface of doc-kit, the Node.js project's toolkit for API documentation. Its doc-kit command reads your docs and runs generators that write a website, the search index, JSON, llms.txt, man pages, or whatever a custom generator produces. Use it to build your docs locally and in CI.

Generator packages are installed separately; see Generators for the package each generator comes from.

npx @doc-kit/cli generate \
  -t html \
  -i "path/to/docs/**/*.md" \
  -o out

A run needs at least a target and an input, from flags or a configuration file. Run npx @doc-kit/cli generate --help, or see the CLI reference, for every option.

To verify the output locally, preview serves it over HTTP. Passing any generate option builds first; otherwise the existing output directory (./out by default) is served as-is, without reading your configuration file.

If your build writes somewhere other than ./out, pass your configuration file (or -o) so it builds and serves that directory:

It builds once and doesn't watch for changes, so run it again after editing.

Warning

The preview server is not meant to be a secure server. Use it for local testing only, and don't expose it to a network. To put your docs online, see Publishing your docs.

Instead of passing flags on every run, put your options in a configuration file. doc-kit looks for one in the working directory, or loads the file you pass with --config-file <path>. A flag wins over the file when both set the same option.

--target, and target in the configuration file, also take a generator you wrote or installed: a relative path such as ./my-generator.mjs (resolved from the working directory), an absolute path, or a package name. The module's default export must have a name and a generate function.

Creating generators shows how to write one.

This package lives in packages/cli of the nodejs/doc-kit monorepo, which uses pnpm. From the repository root:

pnpm install

# Run the CLI from source
pnpm run run generate --help

# Re-run it on every change
pnpm run watch generate -t json -i "path/to/docs/**/*.md" -o out

Each command is a module in bin/commands/; Adding a command walks through writing one. Run the tests with pnpm test, and add a changeset with pnpm changeset for any change users will notice. The contributing guide has the rest.