diff --git a/Makefile b/Makefile index 961682e607272c..4b47a65d154370 100644 --- a/Makefile +++ b/Makefile @@ -932,6 +932,22 @@ out/doc/apilinks.json: $(wildcard lib/*.js) tools/doc/node_modules | out/doc ) \ fi +doc/node.1: + $(error Please use 'make node.1' instead of 'make $@'.) + +.PHONY: node.1 +node.1: doc/api/cli.md tools/doc/node_modules + @if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \ + echo "Skipping $@ (no crypto and/or no ICU)"; \ + else \ + $(call available-node, \ + $(DOC_KIT) generate \ + -v $(VERSION) \ + --config-file tools/doc/man-page.doc-kit.config.mjs \ + -o doc \ + ) \ + fi + .PHONY: docopen docopen: doc-only ## Open the documentation in a web browser. @$(PYTHON) -mwebbrowser file://$(abspath $<) @@ -1480,8 +1496,26 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_ @$(call available-node,$(run-lint-md)) @touch $@ +tools/.manpagelintstamp: doc/node.1 doc/api/cli.md tools/doc/node_modules + $(info Verifying that $< is up to date...) + @if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \ + echo "Skipping $< verification (no crypto and/or no ICU)"; \ + else \ + $(RM) -r out/doc/.manpagecheck && \ + $(call available-node, \ + $(DOC_KIT) generate \ + -v $(VERSION) \ + --config-file tools/doc/man-page.doc-kit.config.mjs \ + ) \ + if ! diff -u $< out/doc/.manpagecheck/node.1; then \ + echo '$< is out of date; run `make node.1` to regenerate it.' >&2; \ + exit 1; \ + fi; \ + fi + @touch $@ + .PHONY: lint-md -lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase. +lint-md: lint-js-doc | tools/.mdlintstamp tools/.manpagelintstamp ## Lint the markdown documents maintained by us in the codebase. run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES) .PHONY: format-md diff --git a/doc/node.1 b/doc/node.1 index 2801d2b3f130ba..9a9016f024026a 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -746,7 +746,8 @@ passing a second \fBparentURL\fR argument for contextual resolution. Previously gated the entire \fBimport.meta.resolve\fR feature. . .It Fl -experimental-import-text -Enable experimental support for importing modules with \fBwith { type: 'text' }\fR. +Enable experimental support for importing modules with +\fBwith { type: 'text' }\fR. . .It Fl -experimental-inspector-network-resource Enable experimental support for inspector network resources. diff --git a/tools/doc/man-page.doc-kit.config.mjs b/tools/doc/man-page.doc-kit.config.mjs new file mode 100644 index 00000000000000..a83f2ca911d34d --- /dev/null +++ b/tools/doc/man-page.doc-kit.config.mjs @@ -0,0 +1,21 @@ +// @node-core/doc-kit configuration for generating and linting the Node.js +// man-page (doc/node.1). + +import { fileURLToPath } from 'node:url'; + +const root = new URL('../../', import.meta.url); + +const fromRoot = (path) => fileURLToPath(new URL(path, root)); + +export default { + target: ['man-page'], + + global: { + input: [fromRoot('doc/api/cli.md')], + output: fromRoot('out/doc/.manpagecheck'), + + // Point every loadable URL at its local file so no network request is made. + changelog: fromRoot('CHANGELOG.md'), + index: fromRoot('doc/api/index.md'), + }, +};