build, doc: move to redesign

Co-authored-by: Brian Muenzenmeyer <brian.muenzenmeyer@gmail.com>
Signed-off-by: avivkeller <me@aviv.sh>
PR-URL: https://github.com/nodejs/node/pull/66713
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Aviv KellerandBrian Muenzenmeyer authored and GitHub committed 2026-11-27 09:19:44 +00:00
1 parent cef4391ab3
commit 08fbdb1273
11 files changed
+1388 -967

No files matched your search

+2 -1
View File
@@ -58,7 +58,8 @@ updates:
semver-minor-days: 5
semver-patch-days: 5
exclude:
- '@node-core/doc-kit'
- '@doc-kit/*'
- '@node-core/*'
commit-message:
prefix: tools
open-pull-requests-limit: 10
+5
View File
@@ -67,6 +67,7 @@ env:
PYTHON_VERSION: '3.15'
FLAKY_TESTS: keep_retrying
CLANG_VERSION: '19'
NODE_VERSION: lts/*
permissions:
contents: read
@@ -84,6 +85,10 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
allow-prereleases: true
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Make tarball
run: |
export DISTTYPE=nightly
+27 -33
View File
@@ -412,7 +412,12 @@ ifeq ($(OSTYPE),os400)
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
endif
DOC_KIT ?= tools/doc/node_modules/@node-core/doc-kit/bin/cli.mjs
DOC_KIT ?= tools/doc/node_modules/@doc-kit/cli/bin/cli.mjs
ifeq ($(V),1)
DOC_KIT_LOG_LEVEL ?= debug
else
DOC_KIT_LOG_LEVEL ?= info
endif
node_use_openssl_and_icu = $(call available-node,"-p" \
"process.versions.openssl != undefined && process.versions.icu != undefined")
@@ -904,56 +909,45 @@ out/doc/api: doc/api
mkdir -p $@
cp -r doc/api out/doc
# Generate all doc files (individual and all.html/all.json) in a single doc-kit call
# Using grouped targets (&:) so Make knows one command produces all outputs
# A single doc-kit call produces every file in apidoc_outputs. They depend on a
# stamp file that the call touches, so Make runs it once rather than once per
# file. (A grouped target, `&:`, would do the same but needs GNU Make 4.3, and
# RHEL 8 ships 4.2.1.)
apidoc_outputs = $(apidocs_html) $(apidocs_json) out/doc/api/all.html \
out/doc/api/all.json out/doc/llms.txt
ifeq ($(OSTYPE),aix)
# TODO(@nodejs/web-infra): AIX is currently hanging during HTML minification
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
$(apidoc_outputs):
@echo "Skipping $@ (not currently supported by $(OSTYPE) machines)"
else ifeq ($(OSTYPE),os400)
# TODO(@nodejs/web-infra): IBMi is currently hanging during HTML minification
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
$(apidoc_outputs):
@echo "Skipping $@ (not currently supported by $(OSTYPE) machines)"
else ifeq ($(ARCHTYPE),riscv64)
# Many riscv64 environments (except qemu) fail on the wasm steps here
# https://github.com/nodejs/build/issues/4099#issuecomment-4038743335
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
$(apidoc_outputs):
@echo "Skipping $@ (not currently supported by $(DESTCPU) machines)"
else
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json &: $(apidoc_sources) tools/doc/node_modules | out/doc/api
out/doc/.docbuildstamp: $(apidoc_sources) tools/doc/node_modules | out/doc/api
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
echo "Skipping $@ (no crypto and/or no ICU)"; \
else \
$(call available-node, \
$(DOC_KIT) generate \
-t legacy-html-all \
-t legacy-json-all \
-i doc/api/*.md \
--log-level $(DOC_KIT_LOG_LEVEL) \
--config-file tools/doc/web.doc-kit.config.mjs \
--ignore $(skip_apidoc_files) \
-o out/doc/api \
-c ./CHANGELOG.md \
-v $(VERSION) \
--index doc/api/index.md \
--type-map doc/type-map.json \
$(if $(JOBS),-p $(JOBS)) \
) \
fi
endif
@touch $@
out/doc/llms.txt: $(apidoc_sources) tools/doc/node_modules | out/doc
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
echo "Skipping $@ (no crypto and/or no ICU)"; \
else \
$(call available-node, \
$(DOC_KIT) generate \
-t llms-txt \
-i doc/api/*.md \
--ignore $(skip_apidoc_files) \
-o $(@D) \
-c ./CHANGELOG.md \
-v $(VERSION) \
--type-map doc/type-map.json \
) \
fi
$(apidoc_outputs): out/doc/.docbuildstamp
endif
out/doc/apilinks.json: $(wildcard lib/*.js) tools/doc/node_modules | out/doc
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
@@ -961,12 +955,10 @@ out/doc/apilinks.json: $(wildcard lib/*.js) tools/doc/node_modules | out/doc
else \
$(call available-node, \
$(DOC_KIT) generate \
-t api-links \
-i lib/*.js \
--log-level $(DOC_KIT_LOG_LEVEL) \
--config-file tools/doc/api-links.doc-kit.config.mjs \
-o $(@D) \
-c ./CHANGELOG.md \
-v $(VERSION) \
--type-map doc/type-map.json \
) \
fi
@@ -980,6 +972,7 @@ node.1: doc/api/cli.md tools/doc/node_modules
else \
$(call available-node, \
$(DOC_KIT) generate \
--log-level $(DOC_KIT_LOG_LEVEL) \
-v $(VERSION) \
--config-file tools/doc/man-page.doc-kit.config.mjs \
-o doc \
@@ -1525,6 +1518,7 @@ tools/.manpagelintstamp: doc/node.1 doc/api/cli.md tools/doc/node_modules
$(RM) -r tools/doc/.manpagecheck && \
$(call available-node, \
$(DOC_KIT) generate \
--log-level $(DOC_KIT_LOG_LEVEL) \
-v $(VERSION) \
--config-file tools/doc/man-page.doc-kit.config.mjs \
) \
+7 -7
View File
@@ -1,9 +1,9 @@
.\"
.\" This file was generated automatically by the @node-core/doc-kit tool.
.\" This file was generated automatically by Node.js's doc-kit tool.
.\" Please do not edit this file manually. Make any updates to cli.md
.\" and regenerate the file afterward.
.\"
.\" To regenerate this file, run `make doc/node.1`.
.\" To regenerate this file, run `make node.1`.
.\"
.\"======================================================================
.Dd $Mdocdate$
@@ -276,7 +276,7 @@ Error: connect ERR_ACCESS_DENIED Access to this API has been restricted. Use --a
.It Fl -allow-openssl-store
When using the Permission Model, the process will not be able to use
OpenSSL STORE loaders by default, for example to load a private key from a
\fB<URL>\fR passed to \fBcrypto.createPrivateKey()\fR. Attempts to do so will throw
\fB{URL}\fR passed to \fBcrypto.createPrivateKey()\fR. Attempts to do so will throw
an \fBERR_ACCESS_DENIED\fR unless the user explicitly passes the
\fB--allow-openssl-store\fR flag. This permission can be dropped at runtime via
\fBpermission.drop()\fR.
@@ -468,11 +468,11 @@ creation behavior.
The following options are currently supported:
.Bl -bullet
.It
\fBbuilder\fR \fB<string>\fR Required. Provides the name to the script that is executed
before building the snapshot, as if \fB--build-snapshot\fR had been passed
\fBbuilder\fR \fB{string}\fR Required. Provides the name to the script that is executed
before building the snapshot, as if \fB--build-snapshot\fR had been passed
with \fBbuilder\fR as the main script name.
.It
\fBwithoutCodeCache\fR \fB<boolean>\fR Optional. Including the code cache reduces the
\fBwithoutCodeCache\fR \fB{boolean}\fR Optional. Including the code cache reduces the
time spent on compiling functions included in the snapshot at the expense
of a bigger snapshot size and potentially breaking portability of the
snapshot.
@@ -2043,7 +2043,7 @@ Print node's version.
.It Fl -vfs-load Ns = Ns Ar source
.Bl -bullet
.It
\fBsource\fR \fB<string>\fR A directory or an archive file to mount and run.
\fBsource\fR \fB{string}\fR A directory or an archive file to mount and run.
.El
May be given at most once.
Mounts \fBsource\fR as a virtual file system (\fBnode:vfs\fR), and runs the entry
+28 -7
View File
@@ -26,17 +26,22 @@ try {
makefile.close();
}
const outdir = new URL('../../out/doc/api', import.meta.url);
const outdir = new URL('../../out/doc/api/', import.meta.url);
const files = await fs.readdir(outdir);
// Explicitly check for `all.html` and `all.json` as there is no corresponding `all.md` file in `doc/api`.
assert(files.includes('all.html'), `all.html was not generated (checked ${files})`);
assert(files.includes('all.json'), `all.json was not generated (checked ${files})`);
// Explicitly check for `index.html`, `all.html` and `all.json` as there are no
// corresponding Markdown files in `doc/api`.
const expectedExtras = ['index.html', 'all.html', 'all.json'];
for (const name of expectedExtras) {
assert(files.includes(name), `${name} was not generated (checked ${files})`);
}
// Check that every markdown file in `doc/api` was processed.
const sources = [];
for await (const file of await fs.opendir(new URL('../../doc/api/', import.meta.url))) {
// Only expect markdown files in doc/api.
assert(path.extname(file.name), 'md');
assert.strictEqual(path.extname(file.name), '.md');
sources.push(path.basename(file.name, '.md'));
// Always expect markdown file in out/doc/api.
assert(files.includes(file.name), `${file.name} not found (checked ${files})`);
@@ -48,7 +53,23 @@ for await (const file of await fs.opendir(new URL('../../doc/api/', import.meta.
assert(!files.includes(htmlFile), `${htmlFile} was unexpectedly generated (checked ${files})`);
assert(!files.includes(jsonFile), `${jsonFile} was unexpectedly generated (checked ${files})`);
} else {
assert(files.includes(htmlFile), `${htmlFile} was not generated (checked ${files})`);
assert(files.includes(jsonFile), `${jsonFile} was not generated (checked ${files})`);
for (const generated of [htmlFile, jsonFile]) {
assert(files.includes(generated), `${generated} was not generated (checked ${files})`);
const { size } = await fs.stat(new URL(generated, outdir));
assert.notStrictEqual(size, 0, `${generated} is empty`);
}
}
}
// Every generated page must come from a current Markdown file, so a stale
// `out/doc/api` (e.g. from a renamed document) is noticed.
const expectedPages = ['404.html', 'apilinks.json', ...expectedExtras];
for (const name of files) {
const extension = path.extname(name);
if (extension !== '.html' && extension !== '.json') continue;
if (expectedPages.includes(name)) continue;
assert(
sources.includes(path.basename(name, extension)),
`Unexpected output: out/doc/api/${name}, remove and rerun.`,
);
}
-74
View File
@@ -1,74 +0,0 @@
import * as common from '../common/index.mjs';
import assert from 'assert';
import fs from 'fs';
import path from 'path';
if (common.isWindows) {
common.skip('`make doc` does not run on Windows');
}
// This tests that `make doc` generates the documentation properly.
// Note that for this test to pass, `make doc` must be run first.
const apiURL = new URL('../../out/doc/api/', import.meta.url);
const mdURL = new URL('../../doc/api/', import.meta.url);
const allMD = fs.readdirSync(mdURL);
const allDocs = fs.readdirSync(apiURL);
assert.ok(allDocs.includes('index.html'));
const actualDocs = allDocs.filter(
(name) => {
const extension = path.extname(name);
return extension === '.html' || extension === '.json';
},
);
for (const name of actualDocs) {
if (name.startsWith('all.') || name === 'apilinks.json') continue;
assert.ok(
allMD.includes(name.replace(/\.\w+$/, '.md')),
`Unexpected output: out/doc/api/${name}, remove and rerun.`,
);
}
const toc = fs.readFileSync(new URL('./index.html', apiURL), 'utf8');
const re = /href=("([^/]+\.html)"|([^/]+\.html))/;
const globalRe = new RegExp(re, 'g');
const links = toc.match(globalRe);
assert.notStrictEqual(links, null);
// Filter out duplicate links, leave just filenames, add expected JSON files.
const linkedHtmls = [...new Set(links)].map((link) => link.match(re)[1])
.concat(['index.html']);
const expectedJsons = linkedHtmls
.map((name) => name.replace('.html', '.json'));
const expectedDocs = linkedHtmls.concat(expectedJsons);
const renamedDocs = ['policy.json', 'policy.html'];
const skipedDocs = ['dtls.json', 'dtls.html', 'quic.json', 'quic.html'];
// Test that all the relative links in the TOC match to the actual documents.
for (const expectedDoc of expectedDocs) {
if (skipedDocs.includes(expectedDoc)) continue;
assert.ok(actualDocs.includes(expectedDoc), `${expectedDoc} does not exist`);
}
// Test that all the actual documents match to the relative links in the TOC
// and that they are not empty files.
for (const actualDoc of actualDocs) {
// When renaming the documentation, the old url is lost
// Unless the old file is still available pointing to the correct location
// 301 redirects are not yet automated. So keeping the old URL is a
// reasonable workaround.
if (renamedDocs.includes(actualDoc) || skipedDocs.includes(actualDoc) ||
actualDoc === 'apilinks.json') continue;
assert.ok(
expectedDocs.includes(actualDoc), `${actualDoc} does not match TOC`);
assert.notStrictEqual(
fs.statSync(new URL(`./${actualDoc}`, apiURL)).size,
0,
`${actualDoc} is empty`,
);
}
+22
View File
@@ -0,0 +1,22 @@
import { fileURLToPath } from 'node:url';
const root = new URL('../../', import.meta.url);
const fromRoot = (path) =>
fileURLToPath(new URL(path, root)).replaceAll('\\', '/');
const urlFromRoot = (path) => new URL(path, root).href;
export default {
extends: '@node-core/doc-kit/config',
target: ['api-links'],
global: {
input: [fromRoot('lib/*.js')],
output: fromRoot('out/doc'),
// Point every loadable URL at its local file so no network request is made.
changelog: urlFromRoot('CHANGELOG.md'),
},
};
+1243 -837
View File
File diff suppressed because it is too large. Load diff
+4 -1
View File
@@ -2,6 +2,9 @@
"name": "doc",
"private": true,
"dependencies": {
"@node-core/doc-kit": "1.4.1"
"@doc-kit/cli": "1.1.1",
"@doc-kit/generator-react": "0.5.2",
"@node-core/doc-kit": "2.0.7",
"@node-core/doc-kit-legacy": "1.1.2"
}
}
+41
View File
@@ -0,0 +1,41 @@
// @node-core/doc-kit configuration for building the API documentation
// (out/doc/api): the HTML site, the JSON consumed by other tooling, and
// `llms.txt`.
import { fileURLToPath } from 'node:url';
const root = new URL('../../', import.meta.url);
const fromRoot = (path) =>
fileURLToPath(new URL(path, root)).replaceAll('\\', '/');
const urlFromRoot = (path) => new URL(path, root).href;
export default {
'extends': '@node-core/doc-kit/config',
'target': [
'legacy-json-all',
'section-pages',
'llms-txt',
],
'global': {
// Files to skip are passed by the Makefile (`skip_apidoc_files`).
input: [fromRoot('doc/api/*.md')],
output: fromRoot('out/doc/api'),
// Point every loadable URL at its local file so no network request is made.
changelog: urlFromRoot('CHANGELOG.md'),
index: urlFromRoot('doc/api/index.md'),
},
'metadata': {
typeMap: urlFromRoot('doc/type-map.json'),
},
// `llms.txt` lives at the root of out/doc, not under out/doc/api.
'llms-txt': {
output: fromRoot('out/doc'),
},
};
+9 -7
View File
@@ -240,7 +240,7 @@ if defined package set stage_package=1
set "node_exe=%config%\node.exe"
set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp"
set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js"
set "doc_kit_exe="%~dp0%node_exe%" %~dp0tools\doc\node_modules\@node-core\doc-kit\bin\cli.mjs"
set "doc_kit_exe="%~dp0%node_exe%" %~dp0tools\doc\node_modules\@doc-kit\cli\bin\cli.mjs"
if "%target_env%"=="vs2022" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2022"
if "%target_env%"=="vs2026" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2026"
@@ -725,13 +725,15 @@ robocopy /e doc\api %config%\doc\api
%doc_kit_exe% ^
generate ^
-t legacy-html-all legacy-json-all api-links ^
-i doc/api/*.md ^
-i lib/*.js ^
--config-file "%~dp0tools\doc\web.doc-kit.config.mjs" ^
-o %config%/doc/api/ ^
-c file://%~dp0\CHANGELOG.md ^
-v %NODE_VERSION% ^
--type-map "file://%~dp0doc\type-map.json"
-v %NODE_VERSION%
%doc_kit_exe% ^
generate ^
--config-file "%~dp0tools\doc\api-links.doc-kit.config.mjs" ^
-o %config%/doc/api/ ^
-v %NODE_VERSION%
:run
@rem Run tests if requested.