Skip to content

Commit a418c13

Browse files
flakey5ovflowd
andcommitted
build, doc: use new api doc tooling
Switches over to using the new doc generation tooling. For more background on this, please see #52343 Signed-off-by: flakey5 <[email protected]> Co-authored-by: Claudio W <[email protected]>
1 parent 09ecd2e commit a418c13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1218
-5473
lines changed

.github/CODEOWNERS

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
/onboarding.md @nodejs/tsc
2323

2424
# nodejs.org website
25-
/doc/api_assets @nodejs/nodejs-website
26-
/doc/template.html @nodejs/nodejs-website
2725
/tools/doc @nodejs/web-infra
2826

2927
# streams

.github/workflows/build-tarball.yml

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ concurrency:
2828
cancel-in-progress: true
2929

3030
env:
31+
NODE_VERSION: lts/*
3132
PYTHON_VERSION: '3.12'
3233
FLAKY_TESTS: keep_retrying
3334
CC: sccache clang
@@ -45,6 +46,10 @@ jobs:
4546
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4647
with:
4748
persist-credentials: false
49+
- name: Install Node.js
50+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
51+
with:
52+
node-version: ${{ env.NODE_VERSION }}
4853
- name: Set up Python ${{ env.PYTHON_VERSION }}
4954
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
5055
with:
@@ -75,6 +80,10 @@ jobs:
7580
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7681
with:
7782
persist-credentials: false
83+
- name: Install Node.js
84+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
85+
with:
86+
node-version: ${{ env.NODE_VERSION }}
7887
- name: Set up Python ${{ env.PYTHON_VERSION }}
7988
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
8089
with:

.github/workflows/tools.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,7 @@ jobs:
123123
label: tools
124124
run: |
125125
cd tools/doc
126-
npm ci
127-
NEW_VERSION=$(npm outdated --parseable | cut -d: -f4 | xargs)
128-
if [ "$NEW_VERSION" != "" ]; then
129-
echo "NEW_VERSION=new version" >> $GITHUB_ENV
130-
rm -rf package-lock.json node_modules
131-
# Include $NEW_VERSION to explicitly update the package.json
132-
# entry for the dependency and also so that semver-major updates
133-
# are not skipped.
134-
npm install --ignore-scripts $NEW_VERSION
135-
npm install --ignore-scripts
136-
fi
126+
./update.sh
137127
- id: googletest
138128
subsystem: deps
139129
label: dependencies, test

Makefile

+19-73
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ NODE_EXE = node$(EXEEXT)
8282
NODE ?= "$(PWD)/$(NODE_EXE)"
8383
NODE_G_EXE = node_g$(EXEEXT)
8484
NPM ?= ./deps/npm/bin/npm-cli.js
85+
NPX ?= ./deps/npm/bin/npx-cli.js
8586

8687
# Flags for packaging.
8788
BUILD_DOWNLOAD_FLAGS ?= --download=all
@@ -333,7 +334,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
333334
# This does not run tests of third-party libraries inside deps.
334335
test: all ## Run default tests, linters, and build docs.
335336
$(MAKE) -s tooltest
336-
$(MAKE) -s test-doc
337337
$(MAKE) -s build-addons
338338
$(MAKE) -s build-js-native-api-tests
339339
$(MAKE) -s build-node-api-tests
@@ -369,7 +369,7 @@ test-valgrind: all ## Run tests using valgrind.
369369
test-check-deopts: all
370370
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
371371

372-
DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
372+
DOCBUILDSTAMP_PREREQS = doc/api/addons.md
373373

374374
ifeq ($(OSTYPE),aix)
375375
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
@@ -385,7 +385,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
385385
echo "Skipping .docbuildstamp (no crypto and/or no ICU)"; \
386386
else \
387387
$(RM) -r test/addons/??_*/; \
388-
[ -x $(NODE) ] && $(NODE) $< || node $< ; \
388+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling -t addon-verify -i doc/api/addons.md -o test/addons/ --lint-dry-run) \
389389
[ $$? -eq 0 ] && touch $@; \
390390
fi
391391

@@ -779,14 +779,10 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
779779
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
780780
endif
781781

782-
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
782+
apidoc_dirs = out/doc out/doc/api
783783
skip_apidoc_files = doc/api/quic.md
784784

785-
apidoc_sources = $(filter-out $(skip_apidoc_files), $(wildcard doc/api/*.md))
786-
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
787-
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
788-
789-
apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
785+
run-npm-ci = $(PWD)/$(NPM) ci
790786

791787
tools/doc/node_modules: tools/doc/package.json
792788
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
@@ -797,11 +793,11 @@ tools/doc/node_modules: tools/doc/package.json
797793

798794
.PHONY: doc-only
799795
doc-only: tools/doc/node_modules \
800-
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
796+
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
801797
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
802-
echo "Skipping doc-only (no crypto and/or no ICU)"; \
798+
echo "Skipping doc-only (no crypto or no icu)"; \
803799
else \
804-
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
800+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling -t legacy-html-all legacy-json-all api-links -i doc/api/\*.md -i lib/\*.js --ignore $(skip_apidoc_files) -o out/doc/api/ --lint-dry-run -c file://$(PWD)/CHANGELOG.md) \
805801
fi
806802

807803
.PHONY: doc
@@ -817,79 +813,24 @@ out/doc/api: doc/api
817813
mkdir -p $@
818814
cp -r doc/api out/doc
819815

820-
# If it's a source tarball, assets are already in doc/api/assets
821-
out/doc/api/assets:
822-
mkdir -p $@
823-
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
824-
825-
# If it's not a source tarball, we need to copy assets from doc/api_assets
826-
out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
827-
@cp $< $@ ; $(RM) out/doc/api/assets/README.md
828-
829-
830-
run-npm-ci = $(PWD)/$(NPM) ci
831-
832-
LINK_DATA = out/doc/apilinks.json
833-
VERSIONS_DATA = out/previous-doc-versions.json
834-
gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
835-
--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
836-
--versions-file=$(VERSIONS_DATA)
837-
gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)
838-
839-
$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
840-
$(call available-node, $(gen-apilink))
841-
842-
# Regenerate previous versions data if the current version changes
843-
$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
844-
$(call available-node, tools/doc/versions.mjs $@)
845-
846-
node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
816+
out/doc/api/%.json out/doc/api/%.html: doc-only
847817

848-
out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.mjs \
849-
tools/doc/markdown.mjs tools/doc/html.mjs tools/doc/json.mjs \
850-
tools/doc/apilinks.mjs $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api
851-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
852-
echo "Skipping documentation generation (no ICU)"; \
853-
else \
854-
$(call available-node, $(gen-api)) \
855-
fi
818+
out/doc/api/all.html: doc-only
856819

857-
out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \
858-
tools/doc/apilinks.mjs | out/doc/api
859-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
860-
echo "Skipping HTML single-page doc generation (no ICU)"; \
861-
else \
862-
$(call available-node, tools/doc/allhtml.mjs) \
863-
fi
864-
865-
out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api
866-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
867-
echo "Skipping JSON single-file generation (no ICU)"; \
868-
else \
869-
$(call available-node, tools/doc/alljson.mjs) \
870-
fi
871-
872-
.PHONY: out/doc/api/stability
873-
out/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api
874-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
875-
echo "Skipping stability indicator generation (no ICU)"; \
876-
else \
877-
$(call available-node, tools/doc/stability.mjs) \
878-
fi
820+
out/doc/api/all.json: doc-only
879821

880822
.PHONY: docopen
881-
docopen: out/doc/api/all.html ## Open the documentation in a web browser.
823+
docopen: doc-only ## Open the documentation in a web browser.
882824
@$(PYTHON) -mwebbrowser file://$(abspath $<)
883825

884826
.PHONY: docserve
885-
docserve: $(apidocs_html) $(apiassets) ## Serve the documentation on localhost:8000.
827+
docserve: doc-only ## Serve the documentation on localhost:8000.
886828
@$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
887829

888830
.PHONY: docclean
889831
.NOTPARALLEL: docclean
890832
docclean: ## Remove the generated documentation.
891833
$(RM) -r out/doc
892-
$(RM) "$(VERSIONS_DATA)"
893834

894835
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
895836
VERSION=v$(RAWVER)
@@ -1396,7 +1337,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
13961337
@touch $@
13971338

13981339
.PHONY: lint-md
1399-
lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1340+
lint-md: lint-js-doc lint-docs | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1341+
1342+
.PHONY: lint-docs
1343+
lint-docs: tools/doc/node_modules
1344+
$(info Running API Doc linter...)
1345+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling -i doc/api/*.md -r github)
14001346

14011347
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
14021348
.PHONY: format-md

doc/api/synopsis.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Usage and example
22

3-
## Usage
4-
53
<!--introduced_in=v0.10.0-->
64

75
<!--type=misc-->
86

7+
## Usage
8+
99
`node [options] [V8 options] [script.js | -e "script" | - ] [arguments]`
1010

1111
Please see the [Command-line options][] document for more information.

doc/api_assets/README.md

-7
This file was deleted.

0 commit comments

Comments
 (0)