## Usage
```sh
$ npx @doc-kit/cli --help
```
```
Usage: doc-kit [options] [command]
CLI tool to generate the Node.js API documentation
Options:
--log-level Log level (choices: "debug", "info", "warn", "error",
"fatal", default: "info")
-h, --help display help for command
Commands:
generate [options] Generate API docs
preview [options] Serve the generated docs locally, building first when any
`generate` option is passed
help [command] display help for command
```
### `generate`
You must provide an input and at least one target through command-line options
or a configuration file. Configuration is discovered automatically using
`cosmiconfig`, or you can select a file explicitly with `--config-file`.
Running `generate` without the required values exits with an error pointing you
to the help output.
```
Usage: doc-kit generate [options]
Generate API docs
Options:
--config-file Config file
-i, --input Input file patterns (glob)
-t, --target Target generator(s): a built-in name
(json, json-all, json-simple, legacy-html,
legacy-html-all, man-page, legacy-json,
legacy-json-all, addon-verify, api-links,
orama-db, llms-txt, llms-txt-full, sitemap,
html, section-pages) or an import specifier
for a custom generator
--ignore Ignore file patterns (glob)
-o, --output The output directory
-p, --threads Number of threads to use (minimum: 1)
--chunk-size Number of items to process per worker thread
(minimum: 1)
-v, --version Target Node.js version
-c, --changelog Changelog URL or path
--git-ref Git ref
--index index.md URL or path
--minify Minify?
--type-map Type map URL or path
-h, --help display help for command
```
### `preview`
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.
It builds once and doesn't watch for changes, so run it again after editing.
```sh
npx @doc-kit/cli preview --host localhost --port 3000
```
```
Usage: doc-kit preview [options]
Serve the generated docs locally, building first when any `generate` option is
passed
Options:
--port Port to serve on (default: 3000)
--host Host to listen on (default: "localhost")
--config-file Config file
-i, --input Input file patterns (glob)
-t, --target Target generator(s): a built-in name (json,
json-all, json-simple, legacy-html,
legacy-html-all, man-page, legacy-json,
legacy-json-all, addon-verify, api-links,
orama-db, llms-txt, llms-txt-full, sitemap, html,
section-pages) or an import specifier for a
custom generator
--ignore Ignore file patterns (glob)
-o, --output The output directory
-p, --threads Number of threads to use (minimum: 1)
--chunk-size Number of items to process per worker thread
(minimum: 1)
-v, --version Target Node.js version
-c, --changelog Changelog URL or path
--git-ref Git ref
--index index.md URL or path
--minify Minify?
--type-map Type map URL or path
-h, --help display help for command
```
> [!WARNING]
> The preview server is meant for local testing only. It is not a secure,
> production-grade server: don't expose it to other machines. To publish your
> docs, see [Publishing your docs](https://doc-kit.nodejs.org/publishing).
## Examples
### Legacy
To generate a 1:1 match with the [legacy tooling](https://github.com/nodejs/node/tree/main/tools/doc), use the `legacy-html`, `legacy-json`, `legacy-html-all`, and `legacy-json-all` generators.
```sh
npx @doc-kit/cli generate \
-t legacy-html \
-t legacy-json \
-i "path/to/node/doc/api/*.md" \
-o out \
--index path/to/node/doc/api/index.md
```
### Redesigned
To generate [our redesigned documentation pages](https://nodejs-api-docs-tooling.vercel.app), use the `html` and `orama-db` (for search) generators. These generators live in the separate [`@doc-kit/generator-react`](packages/react) package, which must be installed alongside this one.
```sh
npx @doc-kit/cli generate \
-t html \
-t orama-db \
-i "path/to/node/doc/api/*.md" \
-o out \
--index path/to/node/doc/api/index.md
```
> [!TIP]
> In order to use the search functionality, you _must_ serve the output directory.
>
> ```sh
> npx @doc-kit/cli preview
> ```