Skip to content

Commit ff4d9ad

Browse files
feat: redesign doc-kit.nodejs.org (#1192)
* docs: rewrite and restructure the documentation Rewrites every page, package README and generator README for clarity and accuracy against the code, and splits the docs into guides, which teach a task with one running example, and reference pages, which list every option. Guides link to the reference instead of repeating it. - `index.md` becomes `introduction.md`, and a new guide covers documenting TypeScript and JSDoc with `@doc-kit/typedoc`. - Every generator page follows one layout: what it makes, what it reads and writes, usage, options, then details. - The specification gains a reading guide, a table of its constructs and examples for every directive, and resolves rules it stated as both MUST and SHOULD. - Code examples whose Markdown bullets the formatter rewrote (the changelog, `index.md` and `llms.txt` samples) are plain text again, so they show what doc-kit actually reads and writes. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): redesign doc-kit.nodejs.org Gives doc-kit's own site a theme of its own, built entirely through the html generator's public extension points (theme slots, components, stylesheets, a template and rehype plugins), so the site doubles as an example of customizing doc-kit. - A home page that shows what doc-kit does: an isometric hero, the sources and outputs of one kittens module, the worker pool building a site, benchmarks and a getting-started path. Its canvases are islands that respect reduced motion. - A neutral palette over `@node-core/ui-components`, with light and dark themes, a cat logo, Inter, and styled search and theme menus. - Five isometric illustrations in the guides, inlined as SVG so they follow the color scheme, each on the one page it explains. - The sidebar groups guides, reference, generators and packages; the build script also takes the site's own pages from `www/pages`, and leaves out the legacy-format generators and the generators documented on another generator's page. Redirects send their old URLs to the sections that now cover them. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(react): replay the press that hydrates an island Islands that hydrate on interaction, such as code tabs and copy buttons, start loading their component on pointerover, focusin or touchstart. The click or tap that follows lands before the component exists, so it did nothing and had to be repeated. The runtime now holds an interaction island's presses until it is hydrated, then dispatches them again, each once the innermost island around it is ready. The site's redesign surfaced this on every code block. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * refactor(www): skip comments instead of stripping them when inlining diagrams The diagram parser removed the XML declaration and comments with one regex replace before tokenizing, which CodeQL flags as incomplete multi-character sanitization: a crafted input could re-form `<!--` after the replace. Each one already arrives as its own token, so the parser now skips those tokens instead. The inlined diagrams are byte-for-byte the same. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * refactor(react): keep the press events with the other UI constants Moves `PRESS_EVENTS` into `ui/constants.mjs`, and says why only a held click is prevented: preventing a pointerdown would also suppress the mouse events that follow it, which are held too, and preventing a mousedown would stop focus and text selection. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * chore(www): make the site its own workspace package The site's dependencies (Inter, Preact and the html generator its theme builds on) move from the root package.json into a private `@doc-kit/www` package, so the root only holds the repo's own tooling again. Preact still resolves to the one copy the html generator uses. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * chore(www): add the source of the social preview image `www/og/og.html` is the card behind `www/public/og.png`, and `node --run og` renders it again with Playwright, in the site's own fonts, so the image can change with the site. It reproduces the current image pixel for pixel. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): make the benchmarks reproducible The home page and the introduction quote build times that were measured by hand. `node --run benchmark` in `www/` now measures them: it builds this site and a Node.js release's API docs, each target on its own and all of them in one run, from a clean output every time, and writes the medians, the page and word counts, the JavaScript the home page loads up front, the machine and the commit to `www/theme/benchmarks.json`, which `data.mjs` reads. The numbers are re-measured with it: five runs each, for this site's 40 pages and the Node.js v26.12.1 API docs. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: give every generator its own page again The site builds every generator's page again, rather than folding json-all, json-simple and llms-txt-full into their parent pages and leaving the legacy-format package out. Their READMEs get their content back, in the layout every generator page shares, and the legacy package's pages are rewritten to match, checked against its code. The overview lists them all, while the sidebar keeps to the main generators. The page globs also merge into one, and the redirects for these pages are gone, as they exist again. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): write the home page in MDX on doc-kit's own code blocks The home page's words and code samples now live in `www/pages/index.mdx` instead of a JSX component, so they're edited like any other page. Its code samples are fenced blocks, highlighted by doc-kit and shown in its own code boxes and tabs, with their copy buttons, which replaces the theme's own highlighter, copy button, code box, install tabs and output tabs. What MDX can't express stays in thin components: the two canvas animations, the sections' layout, and the hand-drawn previews and card art. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: link to one place instead of repeating it Each topic now lives on one page and the others link to it: CLI flags in cli.md, global options and URL templates in configuration.md, type links in writing-docs.md, the typedoc and html READMEs as the references their guides point to. Generator READMEs lose the shared boilerplate, and the internal stages are trimmed down. Snippets use `npx @doc-kit/cli` and are back to what they did on main. The spec is back to main's, flags use the typed-list form doc-kit parses, and statements that documented bugs as behaviour are gone. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(react): scope the heading layout and mark the selected code tab The heading row layout matched any div holding a heading inside <main>, so pages that render their own headings there got it too. API entry headings now carry a `heading` class, and the layout applies to that. With the neutral brand palette, the selected code tab was no brighter than the others, and in dark mode it was dimmer. It now takes the text color, and tabs wrap on narrow screens instead of scrolling out of view. The default template also gets a canonical link, built from `pageURL`, and `theme-color` for both schemes. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * refactor(www): drop the workarounds doc-kit no longer needs The home and 404 pages render a real <main> now that doc-kit's heading layout only applies to API entries, and the code tab and canonical link overrides are gone with doc-kit handling both. The script marking the platform's shortcut key and the last input type is gone too, with the CSS that read it: the search button's label and the theme menu's focus ring come from ui-components, so their fixes go there. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): build the all page and take more from the configuration The all page is built again, and `@node-core/doc-kit-legacy` is back in the sidebar. The home page's components are every export of its module, its count of generators is taken from the repository at build time, and the footer lists the sidebar's pages instead of its own copy of them. On the home page, the hand-drawn site and search previews are gone, leaving the real outputs, the install tabs show up once, and the steps end with `doc-kit preview` now that it has shipped. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs(react): shorten the comment on held presses Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * refactor: move the benchmark to scripts/ and slim it down `scripts/benchmark.mjs` replaces `www/benchmark.mjs`, without the word counts and the copy of the site's sources, and builds every Markdown file in Node.js's `doc/api` instead of leaving `quic.md` out by hand. The home page's data no longer spells out numbers, and the numbers are refreshed. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: make the diagrams self-contained and play them once Each SVG now carries its own styles, light and dark colors, timing, and the subset of Inter and IBM Plex Mono it uses, so it renders the same as a plain image on the site and on GitHub. Images follow the page's color scheme, so they also follow the site's theme switch. The site's rehype plugin that inlined them and the stylesheets that styled them are gone. The motion plays once and holds on the finished picture, which is also what reduced motion shows, instead of looping. dependent.svg no longer shows connectors from section-pages before it has landed, the chips in entry-anatomy.svg sit inside the editor so no leader crosses its edge, and chip labels get more room at their ends. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): draw the home page's animations as SVGs The hero and the pipeline are exported SVGs now, with a narrower drawing of each for phones, and the canvas engine that drew them at runtime, with its two islands, is gone. They're drawn from the same build simulation and layout the canvas used, so they show the same run, and like the guides' diagrams they carry their own styles and fonts and follow the color scheme. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * refactor(www): keep the home page's main landmark on a div ui-components styles everything in a <main> as an article's prose: link colors, heading sizes and spacing, beyond the heading layout doc-kit now scopes to API entries. The home and 404 pages lay out their own content, so they mark it with `role="main"` rather than undo all of it. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * feat(www): polish Kit's head A domed brow between the ears instead of a flat one, softer ear tips, fuller cheeks and a rounder jaw and nose, in the mark, the favicon, the app icon, the hero and the social card. The social card lists only the inputs doc-kit reads itself. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * chore(www): format the social card's source Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(www): bring back the site and search previews Without them, the outputs' three code blocks sat next to each other, so doc-kit grouped them into a second row of tabs inside the first one and left the other two empty. The site preview now shows `options` as the real page does, without a `?`. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: format the guides with oxfmt 0.74 Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(react): replay the press that starts an island loading An island with `interaction: true` starts loading on its first click, from is-land's listener on the island. `holdPresses` attached its listeners in the microtasks after that, too late for the click, so the first click on a button, or Enter or Space on it, did nothing. The runtime now records each press as it starts dispatching, and `holdPresses` also holds the one still being dispatched inside the island, which is the one that started it loading. An e2e spec presses a button that hydrates on its first click with Enter, Space and the mouse. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: measure the benchmarks again now that #1179 has landed This site now builds in 2.4 s and the Node.js v26.12.1 API docs in 9.1 s, on Node.js 26.13. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> * test: add versioned pageURL tests for canonical function * fix(react): link the release line and the index's directory as canonical With Node.js's `pageURL`, `{baseURL}/latest-{version}/api{path}.html`, the canonical link of a page in 26.13.0 pointed at `latest-v26.13.x`, which doesn't exist: `getVersionFromSemVer` keeps a non-zero minor for the version selector's release lines. `{version}` is now the major's release line, `v26.x`, as `pageURL` documents. The index was always linked as `{baseURL}/`, ignoring `pageURL`. It now goes through `pageURL` like any other page, and a trailing `index` or `index.html` is trimmed to its directory, so Node.js's index is `latest-v26.x/api/` and this site's stays `/`. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: bmuenzenmeyer <brian.muenzenmeyer@gmail.com>
1 parent b65d7c1 commit ff4d9ad

95 files changed

Lines changed: 13132 additions & 2261 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@doc-kit/generator-react': patch
3+
---
4+
5+
Replay the presses that hydrate an island, so a code block's first click or tap switches tabs or copies the code, and an island with `interaction: true` runs the click, Enter or Space that started it loading

‎.changeset/quiet-tabs-heading.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@doc-kit/generator-react': patch
3+
---
4+
5+
Scope the heading layout to API entry headings, mark the selected code tab and let tabs wrap on narrow screens, and add a canonical link and `theme-color` to the default template

‎.oxfmtrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"packages/node/src/api-links/__tests__/fixtures/",
3030
"*.snapshot",
3131
"packages/react/src/html/template.html",
32+
"www/theme/template.html",
3233
"out/",
3334
"www/content/",
3435
"www/out/",

‎.oxlintrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
"files": [
208208
"packages/node-legacy/src/legacy-html/assets/*.js",
209209
"packages/react/src/html/ui/**/*",
210+
"www/theme/components/**/*",
210211
"e2e/**/*.spec.js"
211212
],
212213
"globals": {

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ published package lives under `packages/`:
8585
- `packages/typedoc`: [`@doc-kit/typedoc`](packages/typedoc) — the TypeDoc plugin writing API references as doc-kit Markdown
8686

8787
Everything else at the root supports the repo rather than shipping to npm:
88-
`docs/` (every authored documentation page, from the landing page to the
89-
reference docs), `www/` (the documentation site build: its configuration and
90-
gitignored build artifacts), `scripts/` (build and comparison helpers), and
91-
`e2e/` (Playwright tests).
88+
`docs/` (the authored guides and reference docs, plus the illustrations in
89+
`docs/diagrams/`), `www/` (the documentation site: its configuration, its theme
90+
in `www/theme/`, site-only pages such as the home page in `www/pages/`, public
91+
files in `www/public/`, and the gitignored build artifacts in `www/content/`
92+
and `www/out/`), `scripts/` (build and comparison helpers), and `e2e/`
93+
(Playwright tests).
9294

9395
Contributor-facing deep dives — [creating CLI
9496
commands](docs/contributing/commands.md) and [creating

‎docs/cli.md‎

Lines changed: 113 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,135 @@
11
# CLI
22

3-
The `doc-kit` command-line interface. Every option that maps to
4-
configuration can also live in a [configuration file](./configuration.md);
5-
when both are present, CLI flags win (rule of specifity).
3+
The `doc-kit` command builds your docs with `doc-kit generate` and serves
4+
them locally with `doc-kit preview`. It comes from the
5+
[`@doc-kit/cli`](./packages/cli.md) package; install it in your project as
6+
shown in [Getting started](./getting-started.md), then run it with `npx`:
67

78
```bash
89
npx @doc-kit/cli [command] [options]
910
```
1011

11-
One option applies to every command:
12-
13-
- `--log-level <level>` {string} `debug`, `info`, `warn`, `error`, or
14-
`fatal`. **Default:** `'info'`.
12+
`npx @doc-kit/cli --help` lists the commands, and
13+
`npx @doc-kit/cli generate --help` the options of one.
1514

1615
## `doc-kit generate`
1716

17+
Runs the generators and writes their output. It needs at least one target
18+
and an input, from flags or a [configuration file](#configuration-files):
19+
20+
```bash
21+
npx @doc-kit/cli generate -t html -t orama-db -i "docs/**/*.md" -o out
22+
```
23+
24+
Quote glob patterns, so they reach doc-kit as written instead of being
25+
expanded by your shell. Options that take a list accept several values after
26+
one flag (`-t html orama-db`) or the flag repeated (`-t html -t orama-db`).
27+
Each option except `--config-file` sets the configuration key named in
28+
parentheses.
29+
30+
- `-t, --target <name...>` {string[]} Generators to run (`target`): built-in
31+
names, such as `html` or `orama-db`, or the import specifier or path of a
32+
[custom generator](./creating-generators.md). The
33+
[generators overview](./generators.md) lists the built-in ones and the
34+
package each comes from.
35+
- `-i, --input <patterns...>` {string[]} Glob patterns of the files to read
36+
(`global.input`).
37+
- `--ignore <patterns...>` {string[]} Glob patterns of files to leave out
38+
(`global.ignore`).
39+
- `-o, --output <dir>` {string} Directory to write the output to
40+
(`global.output`).
41+
- `--config-file <path>` {string} Path of the configuration file to load,
42+
instead of searching the working directory for one.
43+
- `-v, --version <semver>` {string} Version of the project being documented
44+
(`global.version`), coerced to semver, so `22` means `22.0.0`.
45+
**Default:** the version of Node.js running doc-kit.
46+
- `-c, --changelog <url>` {string} URL or path of a changelog in the format of
47+
Node.js's `CHANGELOG.md`, which the version selector is built from
48+
(`global.changelog`). Without one, the output covers a single version.
49+
- `--index <url>` {string} URL or path of an `index.md` whose list of links
50+
(`* [Title](file.md)`) sets the order of the documents in the JSON bundle,
51+
the legacy HTML sidebar and the legacy JSON bundle (`global.index`).
52+
- `--git-ref <ref>` {string} Git branch, tag, or commit that links into your
53+
repository point to, such as edit links and the JSON output's source URLs
54+
(`global.ref`). The website's source code links follow
55+
[`jsx-ast.ref`](./generators/jsx-ast.md#configuring) instead, which defaults
56+
to `'main'` and is set in a configuration file. **Default:** `'HEAD'`.
57+
- `--type-map <url>` {string} URL or path of a JSON file mapping type names to
58+
the URLs documenting them, used to link types (`metadata.typeMap`).
59+
- `--minify` {boolean} Minify the output (`global.minify`). **Default:**
60+
`false`.
61+
- `-p, --threads <n>` {number} Worker threads to use, at least 1 (`threads`).
62+
**Default:** the number of CPUs, up to 4.
63+
- `--chunk-size <n>` {number} Items each worker processes per task, at least 1
64+
(`chunkSize`). **Default:** `10`.
65+
1866
```bash
19-
npx @doc-kit/cli generate [options]
67+
# Build everything the configuration file describes
68+
npx @doc-kit/cli generate
69+
70+
# Build only the JSON output, minified, into dist/json
71+
npx @doc-kit/cli generate -t json -o dist/json --minify
2072
```
2173

22-
Runs the generators and writes their output. Requires a `target` and an
23-
`input`, from flags or the configuration file.
24-
25-
- `--config-file <path>` {string} Use a specific configuration file instead
26-
of searching.
27-
- `-i, --input <patterns...>` {string[]} Input file patterns (glob).
28-
- `-t, --target <name...>` {string[]} Generator name(s), or import
29-
specifiers for custom generators.
30-
- `--ignore <patterns...>` {string[]} Input patterns to skip.
31-
- `-o, --output <dir>` {string} The output directory.
32-
- `-v, --version <semver>` {string} The version of the project being
33-
documented.
34-
- `-c, --changelog <url>` {string} Changelog URL or path (release history
35-
for version selectors).
36-
- `--git-ref <ref>` {string} Git ref used in source links.
37-
- `--index <url>` {string} `index.md` URL or path.
38-
- `--minify` {boolean} Minify the output.
39-
- `--type-map <url>` {string} Type map URL or path (custom type-name → URL
40-
links).
41-
- `-p, --threads <n>` {number} Worker threads to use (minimum 1).
42-
- `--chunk-size <n>` {number} Items per worker thread (minimum 1).
74+
When something fails, doc-kit logs the error and exits with code 1, so a
75+
broken build also fails your CI job.
4376

4477
## `doc-kit preview`
4578

79+
Serves the output directory over HTTP at <http://localhost:3000>, so you can
80+
check a build in the browser the way a host would serve it:
81+
4682
```bash
4783
npx @doc-kit/cli preview [options]
4884
```
4985

50-
Serves the generated docs over HTTP for local verification. Every `generate`
51-
option is accepted: when any of them is passed, the docs are built first
52-
(same semantics as `doc-kit generate`); otherwise the existing output
53-
directory is served as-is (`./out` by default).
86+
What it serves depends on the options you pass:
87+
88+
- **No `generate` options:** it serves `./out` as it is, without reading your
89+
configuration file, and stops with an error if `./out` doesn't exist.
90+
- **Any `generate` option:** it builds first, exactly as `doc-kit generate`
91+
would, then serves the directory that build wrote to. To build from your
92+
configuration file alone, pass it with `--config-file`.
93+
94+
It builds once and doesn't watch for changes, so run it again after editing.
95+
Directories serve their `index.html`, and paths that don't exist get the
96+
output's `404.html`, when it has one.
97+
98+
It takes these options, plus every option of
99+
[`doc-kit generate`](#doc-kit-generate):
100+
101+
- `--port <n>` {number} Port to serve on; `0` picks a free one. **Default:**
102+
`3000`.
103+
- `--host <host>` {string} Host to listen on. **Default:** `'localhost'`.
104+
105+
```bash
106+
# Build with the configuration file, then serve its output directory
107+
npx @doc-kit/cli preview --config-file doc-kit.config.mjs
108+
109+
# Build only the site, then serve it on another port
110+
npx @doc-kit/cli preview -t html --port 8080
111+
```
112+
113+
> [!WARNING]
114+
> The preview server is meant for local testing only. It is not a secure,
115+
> production-grade server: don't expose it to other machines, and don't use
116+
> it to deploy your documentation. To publish, see
117+
> [Publishing your docs](./publishing.md).
118+
119+
## Global options
120+
121+
These work with every command, before or after its name:
122+
123+
- `--log-level <level>` {string} Log only messages at this level or above:
124+
`debug`, `info`, `warn`, `error`, or `fatal`. **Default:** `'info'`.
125+
126+
```bash
127+
npx @doc-kit/cli generate --log-level debug
128+
```
54129

55-
> **Note:** The preview server is meant for local testing only — it is not
56-
> production grade. Do not use it to deploy your documentation.
130+
## Configuration files
57131

58-
- `--port <n>` {number} Port to serve on. **Default:** `3000`.
59-
- `--host <host>` {string} Host to listen on (e.g. `localhost`, `0.0.0.0`).
60-
**Default:** `'localhost'`.
61-
- Every option of [`doc-kit generate`](#doc-kit-generate).
132+
Everything the `generate` flags set can also live in a
133+
[configuration file](./configuration.md), along with what they don't cover,
134+
such as generator options, Markdown plugins, and presets. Flags win over the
135+
file; see [Precedence](./configuration.md#precedence).

0 commit comments

Comments
 (0)