Skip to content

Commit 08fbdb1

Browse files
build, doc: move to redesign
Co-authored-by: Brian Muenzenmeyer <brian.muenzenmeyer@gmail.com> Signed-off-by: avivkeller <me@aviv.sh> PR-URL: #66713 Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent cef4391 commit 08fbdb1

11 files changed

Lines changed: 1412 additions & 991 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ updates:
5858
semver-minor-days: 5
5959
semver-patch-days: 5
6060
exclude:
61-
- '@node-core/doc-kit'
61+
- '@doc-kit/*'
62+
- '@node-core/*'
6263
commit-message:
6364
prefix: tools
6465
open-pull-requests-limit: 10

‎.github/workflows/build-tarball.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ env:
6767
PYTHON_VERSION: '3.15'
6868
FLAKY_TESTS: keep_retrying
6969
CLANG_VERSION: '19'
70+
NODE_VERSION: lts/*
7071

7172
permissions:
7273
contents: read
@@ -84,6 +85,10 @@ jobs:
8485
with:
8586
python-version: ${{ env.PYTHON_VERSION }}
8687
allow-prereleases: true
88+
- name: Use Node.js ${{ env.NODE_VERSION }}
89+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
90+
with:
91+
node-version: ${{ env.NODE_VERSION }}
8792
- name: Make tarball
8893
run: |
8994
export DISTTYPE=nightly

‎Makefile‎

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,12 @@ ifeq ($(OSTYPE),os400)
412412
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
413413
endif
414414

415-
DOC_KIT ?= tools/doc/node_modules/@node-core/doc-kit/bin/cli.mjs
415+
DOC_KIT ?= tools/doc/node_modules/@doc-kit/cli/bin/cli.mjs
416+
ifeq ($(V),1)
417+
DOC_KIT_LOG_LEVEL ?= debug
418+
else
419+
DOC_KIT_LOG_LEVEL ?= info
420+
endif
416421

417422
node_use_openssl_and_icu = $(call available-node,"-p" \
418423
"process.versions.openssl != undefined && process.versions.icu != undefined")
@@ -904,69 +909,56 @@ out/doc/api: doc/api
904909
mkdir -p $@
905910
cp -r doc/api out/doc
906911

907-
# Generate all doc files (individual and all.html/all.json) in a single doc-kit call
908-
# Using grouped targets (&:) so Make knows one command produces all outputs
912+
# A single doc-kit call produces every file in apidoc_outputs. They depend on a
913+
# stamp file that the call touches, so Make runs it once rather than once per
914+
# file. (A grouped target, `&:`, would do the same but needs GNU Make 4.3, and
915+
# RHEL 8 ships 4.2.1.)
916+
apidoc_outputs = $(apidocs_html) $(apidocs_json) out/doc/api/all.html \
917+
out/doc/api/all.json out/doc/llms.txt
918+
909919
ifeq ($(OSTYPE),aix)
910920
# TODO(@nodejs/web-infra): AIX is currently hanging during HTML minification
911-
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
921+
$(apidoc_outputs):
912922
@echo "Skipping $@ (not currently supported by $(OSTYPE) machines)"
913923
else ifeq ($(OSTYPE),os400)
914924
# TODO(@nodejs/web-infra): IBMi is currently hanging during HTML minification
915-
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
925+
$(apidoc_outputs):
916926
@echo "Skipping $@ (not currently supported by $(OSTYPE) machines)"
917927
else ifeq ($(ARCHTYPE),riscv64)
918928
# Many riscv64 environments (except qemu) fail on the wasm steps here
919929
# https://github.com/nodejs/build/issues/4099#issuecomment-4038743335
920-
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json:
930+
$(apidoc_outputs):
921931
@echo "Skipping $@ (not currently supported by $(DESTCPU) machines)"
922932
else
923-
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json &: $(apidoc_sources) tools/doc/node_modules | out/doc/api
933+
out/doc/.docbuildstamp: $(apidoc_sources) tools/doc/node_modules | out/doc/api
924934
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
925935
echo "Skipping $@ (no crypto and/or no ICU)"; \
926936
else \
927937
$(call available-node, \
928938
$(DOC_KIT) generate \
929-
-t legacy-html-all \
930-
-t legacy-json-all \
931-
-i doc/api/*.md \
939+
--log-level $(DOC_KIT_LOG_LEVEL) \
940+
--config-file tools/doc/web.doc-kit.config.mjs \
932941
--ignore $(skip_apidoc_files) \
933942
-o out/doc/api \
934-
-c ./CHANGELOG.md \
935943
-v $(VERSION) \
936-
--index doc/api/index.md \
937-
--type-map doc/type-map.json \
944+
$(if $(JOBS),-p $(JOBS)) \
938945
) \
939946
fi
940-
endif
947+
@touch $@
941948

942-
out/doc/llms.txt: $(apidoc_sources) tools/doc/node_modules | out/doc
943-
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
944-
echo "Skipping $@ (no crypto and/or no ICU)"; \
945-
else \
946-
$(call available-node, \
947-
$(DOC_KIT) generate \
948-
-t llms-txt \
949-
-i doc/api/*.md \
950-
--ignore $(skip_apidoc_files) \
951-
-o $(@D) \
952-
-c ./CHANGELOG.md \
953-
-v $(VERSION) \
954-
--type-map doc/type-map.json \
955-
) \
956-
fi
949+
$(apidoc_outputs): out/doc/.docbuildstamp
950+
endif
957951

958952
out/doc/apilinks.json: $(wildcard lib/*.js) tools/doc/node_modules | out/doc
959953
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
960954
echo "Skipping $@ (no crypto and/or no ICU)"; \
961955
else \
962956
$(call available-node, \
963957
$(DOC_KIT) generate \
964-
-t api-links \
965-
-i lib/*.js \
958+
--log-level $(DOC_KIT_LOG_LEVEL) \
959+
--config-file tools/doc/api-links.doc-kit.config.mjs \
966960
-o $(@D) \
967-
-c ./CHANGELOG.md \
968961
-v $(VERSION) \
969-
--type-map doc/type-map.json \
970962
) \
971963
fi
972964

@@ -980,6 +972,7 @@ node.1: doc/api/cli.md tools/doc/node_modules
980972
else \
981973
$(call available-node, \
982974
$(DOC_KIT) generate \
975+
--log-level $(DOC_KIT_LOG_LEVEL) \
983976
-v $(VERSION) \
984977
--config-file tools/doc/man-page.doc-kit.config.mjs \
985978
-o doc \
@@ -1525,6 +1518,7 @@ tools/.manpagelintstamp: doc/node.1 doc/api/cli.md tools/doc/node_modules
15251518
$(RM) -r tools/doc/.manpagecheck && \
15261519
$(call available-node, \
15271520
$(DOC_KIT) generate \
1521+
--log-level $(DOC_KIT_LOG_LEVEL) \
15281522
-v $(VERSION) \
15291523
--config-file tools/doc/man-page.doc-kit.config.mjs \
15301524
) \

‎doc/node.1‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.\"
2-
.\" This file was generated automatically by the @node-core/doc-kit tool.
2+
.\" This file was generated automatically by Node.js's doc-kit tool.
33
.\" Please do not edit this file manually. Make any updates to cli.md
44
.\" and regenerate the file afterward.
55
.\"
6-
.\" To regenerate this file, run `make doc/node.1`.
6+
.\" To regenerate this file, run `make node.1`.
77
.\"
88
.\"======================================================================
99
.Dd $Mdocdate$
@@ -276,7 +276,7 @@ Error: connect ERR_ACCESS_DENIED Access to this API has been restricted. Use --a
276276
.It Fl -allow-openssl-store
277277
When using the Permission Model, the process will not be able to use
278278
OpenSSL STORE loaders by default, for example to load a private key from a
279-
\fB<URL>\fR passed to \fBcrypto.createPrivateKey()\fR. Attempts to do so will throw
279+
\fB{URL}\fR passed to \fBcrypto.createPrivateKey()\fR. Attempts to do so will throw
280280
an \fBERR_ACCESS_DENIED\fR unless the user explicitly passes the
281281
\fB--allow-openssl-store\fR flag. This permission can be dropped at runtime via
282282
\fBpermission.drop()\fR.
@@ -468,11 +468,11 @@ creation behavior.
468468
The following options are currently supported:
469469
.Bl -bullet
470470
.It
471-
\fBbuilder\fR \fB<string>\fR Required. Provides the name to the script that is executed
472-
before building the snapshot, as if \fB--build-snapshot\fR had been passed
471+
\fBbuilder\fR \fB{string}\fR Required. Provides the name to the script that is executed
472+
before building the snapshot, as if \fB--build-snapshot\fR had been passed
473473
with \fBbuilder\fR as the main script name.
474474
.It
475-
\fBwithoutCodeCache\fR \fB<boolean>\fR Optional. Including the code cache reduces the
475+
\fBwithoutCodeCache\fR \fB{boolean}\fR Optional. Including the code cache reduces the
476476
time spent on compiling functions included in the snapshot at the expense
477477
of a bigger snapshot size and potentially breaking portability of the
478478
snapshot.
@@ -2043,7 +2043,7 @@ Print node's version.
20432043
.It Fl -vfs-load Ns = Ns Ar source
20442044
.Bl -bullet
20452045
.It
2046-
\fBsource\fR \fB<string>\fR A directory or an archive file to mount and run.
2046+
\fBsource\fR \fB{string}\fR A directory or an archive file to mount and run.
20472047
.El
20482048
May be given at most once.
20492049
Mounts \fBsource\fR as a virtual file system (\fBnode:vfs\fR), and runs the entry

‎test/doctool/test-docs.mjs‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@ try {
2626
makefile.close();
2727
}
2828

29-
const outdir = new URL('../../out/doc/api', import.meta.url);
29+
const outdir = new URL('../../out/doc/api/', import.meta.url);
3030
const files = await fs.readdir(outdir);
3131

32-
// Explicitly check for `all.html` and `all.json` as there is no corresponding `all.md` file in `doc/api`.
33-
assert(files.includes('all.html'), `all.html was not generated (checked ${files})`);
34-
assert(files.includes('all.json'), `all.json was not generated (checked ${files})`);
32+
// Explicitly check for `index.html`, `all.html` and `all.json` as there are no
33+
// corresponding Markdown files in `doc/api`.
34+
const expectedExtras = ['index.html', 'all.html', 'all.json'];
35+
for (const name of expectedExtras) {
36+
assert(files.includes(name), `${name} was not generated (checked ${files})`);
37+
}
3538

3639
// Check that every markdown file in `doc/api` was processed.
40+
const sources = [];
3741
for await (const file of await fs.opendir(new URL('../../doc/api/', import.meta.url))) {
3842
// Only expect markdown files in doc/api.
39-
assert(path.extname(file.name), 'md');
43+
assert.strictEqual(path.extname(file.name), '.md');
44+
sources.push(path.basename(file.name, '.md'));
4045

4146
// Always expect markdown file in out/doc/api.
4247
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.
4853
assert(!files.includes(htmlFile), `${htmlFile} was unexpectedly generated (checked ${files})`);
4954
assert(!files.includes(jsonFile), `${jsonFile} was unexpectedly generated (checked ${files})`);
5055
} else {
51-
assert(files.includes(htmlFile), `${htmlFile} was not generated (checked ${files})`);
52-
assert(files.includes(jsonFile), `${jsonFile} was not generated (checked ${files})`);
56+
for (const generated of [htmlFile, jsonFile]) {
57+
assert(files.includes(generated), `${generated} was not generated (checked ${files})`);
58+
const { size } = await fs.stat(new URL(generated, outdir));
59+
assert.notStrictEqual(size, 0, `${generated} is empty`);
60+
}
5361
}
5462
}
63+
64+
// Every generated page must come from a current Markdown file, so a stale
65+
// `out/doc/api` (e.g. from a renamed document) is noticed.
66+
const expectedPages = ['404.html', 'apilinks.json', ...expectedExtras];
67+
for (const name of files) {
68+
const extension = path.extname(name);
69+
if (extension !== '.html' && extension !== '.json') continue;
70+
if (expectedPages.includes(name)) continue;
71+
assert(
72+
sources.includes(path.basename(name, extension)),
73+
`Unexpected output: out/doc/api/${name}, remove and rerun.`,
74+
);
75+
}

‎test/doctool/test-make-doc.mjs‎

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { fileURLToPath } from 'node:url';
2+
3+
const root = new URL('../../', import.meta.url);
4+
5+
const fromRoot = (path) =>
6+
fileURLToPath(new URL(path, root)).replaceAll('\\', '/');
7+
8+
const urlFromRoot = (path) => new URL(path, root).href;
9+
10+
export default {
11+
extends: '@node-core/doc-kit/config',
12+
13+
target: ['api-links'],
14+
15+
global: {
16+
input: [fromRoot('lib/*.js')],
17+
output: fromRoot('out/doc'),
18+
19+
// Point every loadable URL at its local file so no network request is made.
20+
changelog: urlFromRoot('CHANGELOG.md'),
21+
},
22+
};

0 commit comments

Comments
 (0)