The doc-kit command builds your docs with doc-kit generate and serves
them locally with doc-kit preview. It comes from the
@doc-kit/cli package; install it in your project as
shown in Getting started, then run it with npx:
npx doc-kit <command> [options]
npx doc-kit --help lists the commands, and npx doc-kit generate --help
the options of one.
Runs the generators and writes their output. It needs at least one target and an input, from flags or a configuration file:
npx doc-kit generate -t html -t orama-db -i "docs/**/*.md" -o out
Quote glob patterns, so they reach doc-kit as written instead of being
expanded by your shell. Options that take a list accept several values after
one flag (-t html orama-db) or the flag repeated (-t html -t orama-db).
Each option except --config-file sets the configuration key named in
parentheses.
-t,--targetstring[]Generators to run (target): built-in names, such ashtmlororama-db(see the generators overview), or the import specifier or path of a custom generator. Onlyjson,json-all, andjson-simplecome with the CLI. The others come from packages you install next to it, such as@doc-kit/generator-reactforhtml,orama-db, and the other web generators, and@node-core/doc-kitforman-page,api-links, andaddon-verify.-i,--inputstring[]Glob patterns of the files to read (global.input).--ignorestring[]Glob patterns of files to leave out (global.ignore).-o,--outputstringDirectory to write the output to (global.output).--config-filestringPath of the configuration file to load, instead of searching the working directory for one.-v,--versionstringVersion of the project being documented (global.version), coerced to semver, so22means22.0.0. Default: the version of Node.js running doc-kit.-c,--changelogstringURL or path of a changelog in the format of Node.js'sCHANGELOG.md, which the version selector is built from (global.changelog). Without one, the output covers a single version.--indexstringURL or path of anindex.mdwhose list of links (* [Title](file.md)) sets the order of the documents in the JSON bundle (global.index).--git-refstringGit branch, tag, or commit that links into your repository point to, such as edit links and the JSON output's source URLs (global.ref). The website's source code links followjsx-ast.refinstead, which defaults to'main'and is set in a configuration file. Default:'HEAD'.--type-mapstringURL or path of a JSON file mapping type names to the URLs documenting them, used to link types (metadata.typeMap).--minifybooleanMinify the output (global.minify). Default:false.-p,--threadsnumberWorker threads to use, at least 1 (threads). Default: the number of CPUs, up to 4.--chunk-sizenumberItems each worker processes per task, at least 1 (chunkSize). Default:10.
# Build everything the configuration file describes npx doc-kit generate # Build only the JSON output, minified, into dist/json npx doc-kit generate -t json -o dist/json --minify
When something fails, doc-kit logs the error and exits with code 1, so a broken build also fails your CI job.
Serves the output directory over HTTP at http://localhost:3000, so you can check a build in the browser the way a host would serve it:
npx doc-kit preview
What it serves depends on the options you pass:
- No
generateoptions: it serves./outas it is, without reading your configuration file, and stops with an error if./outdoesn't exist. - Any
generateoption: it builds first, exactly asdoc-kit generatewould, then serves the directory that build wrote to. To build from your configuration file alone, pass it with--config-file.
It builds once and doesn't watch for changes, so run it again after editing.
Directories serve their index.html, and paths that don't exist get the
output's 404.html, when it has one.
It takes these options, plus every option of
doc-kit generate:
# Build with the configuration file, then serve its output directory npx doc-kit preview --config-file doc-kit.config.mjs # Build only the site, then serve it on another port npx doc-kit preview -t html --port 8080
The preview server is for local testing, not for production. To publish, upload the output directory to a static host; see Publishing your docs.
These work with every command, before or after its name:
stringdebug,
info, warn, error, or fatal. Default: 'info'.npx doc-kit generate --log-level debug
Everything the generate flags set can also live in a configuration file,
along with what they don't cover, such as generator options, Markdown plugins,
and presets. Without --config-file, doc-kit looks for one in the working
directory, such as doc-kit.config.mjs, .doc-kitrc.yml, or a doc-kit key
in package.json. See
Where configuration lives for
every name it tries.
Flags win over the file. A flag that takes a list, such as --target,
replaces the configured list instead of adding to it. See
Configuration for the file's format and every key.