Skip to content

Commit a3ce99d

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 823c9b7 commit a3ce99d

Some content is hidden

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

50 files changed

+1095
-5746
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/label-pr-config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ exlusiveLabels:
115115
# More specific tests
116116
/^test\/addons\//: test, addons
117117
/^test\/debugger/: test, debugger
118-
/^test\/doctool\//: test, doc, tools
119118
/^test\/timers/: test, timers
120119
/^test\/pseudo-tty\//: test, tty
121120
/^test\/inspector/: test, inspector

.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

+27-93
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
@@ -103,6 +104,16 @@ available-node = \
103104
exit 1; \
104105
fi;
105106

107+
available-npx = \
108+
if [ -x "$(NPX)" ] && [ -e "$(NPX)" ]; then \
109+
"$(NPX)" $(1); \
110+
elif [ -x `command -v npx` ] && [ -e `command -v npx` ] && [ `command -v npx` ]; then \
111+
`command -v npx` $(1); \
112+
else \
113+
echo "No available npx, cannot run \"npx $(1)\""; \
114+
exit 1; \
115+
fi;
116+
106117
.PHONY: all
107118
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
108119
# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
@@ -333,7 +344,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
333344
# This does not run tests of third-party libraries inside deps.
334345
test: all ## Run default tests, linters, and build docs.
335346
$(MAKE) -s tooltest
336-
$(MAKE) -s test-doc
337347
$(MAKE) -s build-addons
338348
$(MAKE) -s build-js-native-api-tests
339349
$(MAKE) -s build-node-api-tests
@@ -369,7 +379,7 @@ test-valgrind: all ## Run tests using valgrind.
369379
test-check-deopts: all
370380
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
371381

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

374384
ifeq ($(OSTYPE),aix)
375385
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
@@ -385,7 +395,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
385395
echo "Skipping .docbuildstamp (no crypto and/or no ICU)"; \
386396
else \
387397
$(RM) -r test/addons/??_*/; \
388-
[ -x $(NODE) ] && $(NODE) $< || node $< ; \
398+
$(call available-npx, --prefix $< api-docs-tooling -t addon-verify -i doc/api/addons.md -o test/addons/) \
389399
[ $$? -eq 0 ] && touch $@; \
390400
fi
391401

@@ -559,11 +569,6 @@ NATIVE_SUITES ?= addons js-native-api node-api
559569
# CI_* variables should be kept synchronized with the ones in vcbuild.bat
560570
CI_NATIVE_SUITES ?= $(NATIVE_SUITES) benchmark
561571
CI_JS_SUITES ?= $(JS_SUITES) pummel
562-
ifeq ($(node_use_openssl_and_icu), false)
563-
CI_DOC := doctool
564-
else
565-
CI_DOC =
566-
endif
567572

568573
.PHONY: test-ci-native
569574

@@ -596,7 +601,7 @@ test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tes
596601
out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
597602
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
598603
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
599-
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
604+
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES)
600605
$(NODE) ./test/embedding/test-embedding.js
601606
$(info Clean up any leftover processes, error if found.)
602607
ps awwx | grep Release/node | grep -v grep | cat
@@ -658,18 +663,6 @@ test-tick-processor: all ## Run tick processor tests.
658663
test-hash-seed: all ## Verifu that the hash seed used by V8 for hashing is random.
659664
$(NODE) test/pummel/test-hash-seed.js
660665

661-
.PHONY: test-doc
662-
test-doc: doc-only lint-md ## Build, lint, and verify the docs.
663-
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
664-
echo "Skipping test-doc (no crypto and/or no ICU)"; \
665-
else \
666-
$(PYTHON) tools/test.py $(PARALLEL_ARGS) doctool; \
667-
fi
668-
669-
.PHONY: test-doc-ci
670-
test-doc-ci: doc-only ## Build, lint, and verify the docs (CI).
671-
$(PYTHON) tools/test.py --shell $(NODE) $(TEST_CI_ARGS) $(PARALLEL_ARGS) doctool
672-
673666
.PHONY: test-known-issues
674667
test-known-issues: all ## Run tests for known issues.
675668
$(PYTHON) tools/test.py $(PARALLEL_ARGS) known_issues
@@ -779,14 +772,10 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
779772
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
780773
endif
781774

782-
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
775+
apidoc_dirs = out/doc out/doc/api
783776
skip_apidoc_files = doc/api/quic.md
784777

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/*)))
778+
run-npm-ci = $(PWD)/$(NPM) ci
790779

791780
tools/doc/node_modules: tools/doc/package.json
792781
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
@@ -797,11 +786,11 @@ tools/doc/node_modules: tools/doc/package.json
797786

798787
.PHONY: doc-only
799788
doc-only: tools/doc/node_modules \
800-
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
789+
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
801790
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
802-
echo "Skipping doc-only (no crypto and/or no ICU)"; \
791+
echo "Skipping doc-only (no crypto or no icu)"; \
803792
else \
804-
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
793+
$(call available-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/ -c file://$(PWD)/CHANGELOG.md) \
805794
fi
806795

807796
.PHONY: doc
@@ -817,72 +806,12 @@ out/doc/api: doc/api
817806
mkdir -p $@
818807
cp -r doc/api out/doc
819808

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'")
847-
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
856-
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
879-
880809
.PHONY: docopen
881-
docopen: out/doc/api/all.html ## Open the documentation in a web browser.
810+
docopen: doc-only ## Open the documentation in a web browser.
882811
@$(PYTHON) -mwebbrowser file://$(abspath $<)
883812

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

888817
.PHONY: docclean
@@ -1396,7 +1325,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
13961325
@touch $@
13971326

13981327
.PHONY: lint-md
1399-
lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1328+
lint-md: lint-js-doc lint-docs | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1329+
1330+
.PHONY: lint-docs
1331+
lint-docs: tools/doc/node_modules
1332+
$(info Running API Doc linter...)
1333+
$(call available-npx, --prefix tools/doc api-docs-tooling -i doc/api/*.md)
14001334

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

doc/api/index.md

-79
This file was deleted.

doc/api_assets/README.md

-7
This file was deleted.

0 commit comments

Comments
 (0)