From 35fc9c7be3dab32aedd251e713e8a2557bbd0832 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 27 Nov 2026 11:00:44 +0800 Subject: [PATCH] docs: document the `preview` command in the root README --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 00c1c01e0..2106ae8d0 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Options: 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 ``` @@ -89,6 +91,54 @@ Options: -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 @@ -121,5 +171,5 @@ npx @doc-kit/cli generate \ > In order to use the search functionality, you _must_ serve the output directory. > > ```sh -> npx serve out +> npx @doc-kit/cli preview > ```