Skip to content

Commit a8ca37d

Browse files
flakey5ovflowdavivkelleraduh95
committed
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]> Co-authored-by: avivkeller <[email protected]> Co-authored-by: Antoine du Hamel <[email protected]>
1 parent cb0eb58 commit a8ca37d

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

+7801
-6168
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
/onboarding.md @nodejs/tsc
2424

2525
# nodejs.org website
26-
/doc/api_assets @nodejs/nodejs-website
27-
/doc/template.html @nodejs/nodejs-website
2826
/tools/doc @nodejs/web-infra
2927

3028
# streams

.github/workflows/tools.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ jobs:
120120
run: |
121121
make corepack-update
122122
echo "NEW_VERSION=$(node deps/corepack/dist/corepack.js --version)" >> $GITHUB_ENV
123+
- id: doc
124+
subsystem: tools
125+
label: tools
126+
run: |
127+
cd tools/doc
128+
./update.sh
123129
- id: googletest
124130
subsystem: deps
125131
label: dependencies, test

Makefile

Lines changed: 38 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ FIND ?= find
2626

2727
ifdef JOBS
2828
PARALLEL_ARGS = -j $(JOBS)
29+
30+
# Amount of worker threads to create for generating documentation files
31+
DOC_JOBS = $(JOBS)
2932
else
3033
PARALLEL_ARGS =
34+
DOC_JOBS = 12
3135
endif
3236

3337
ifdef ENABLE_V8_TAP
@@ -80,6 +84,7 @@ EXEEXT := $(shell $(PYTHON) -c \
8084
NODE_EXE = node$(EXEEXT)
8185
NODE_G_EXE = node_g$(EXEEXT)
8286
NPM ?= ./deps/npm/bin/npm-cli.js
87+
NPX ?= ./deps/npm/bin/npx-cli.js
8388

8489
# Release build of node.
8590
# Use $(PWD) so we can cd to anywhere before calling this.
@@ -341,7 +346,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
341346
# This does not run tests of third-party libraries inside deps.
342347
test: all ## Run default tests, linters, and build docs.
343348
$(MAKE) -s tooltest
344-
$(MAKE) -s test-doc
345349
$(MAKE) -s build-addons
346350
$(MAKE) -s build-js-native-api-tests
347351
$(MAKE) -s build-node-api-tests
@@ -377,7 +381,7 @@ test-valgrind: all ## Run tests using valgrind.
377381
test-check-deopts: all
378382
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
379383

380-
DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
384+
DOCBUILDSTAMP_PREREQS = doc/api/addons.md
381385

382386
ifeq ($(OSTYPE),aix)
383387
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
@@ -393,7 +397,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
393397
echo "Skipping .docbuildstamp (no crypto and/or no ICU)"; \
394398
else \
395399
$(RM) -r test/addons/??_*/; \
396-
[ -x $(NODE) ] && $(NODE) $< || node $< ; \
400+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling generate -t addon-verify -i doc/api/addons.md -o test/addons/ --skip-lint) \
397401
[ $$? -eq 0 ] && touch $@; \
398402
fi
399403

@@ -789,14 +793,14 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
789793
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
790794
endif
791795

792-
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
796+
apidoc_dirs = out/doc out/doc/api
793797
skip_apidoc_files = doc/api/quic.md
794798

795799
apidoc_sources = $(filter-out $(skip_apidoc_files), $(wildcard doc/api/*.md))
796800
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
797801
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
798802

799-
apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
803+
run-npm-ci = $(PWD)/$(NPM) ci --omit=dev
800804

801805
tools/doc/node_modules: tools/doc/package.json
802806
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
@@ -805,13 +809,16 @@ tools/doc/node_modules: tools/doc/package.json
805809
cd tools/doc && $(call available-node,$(run-npm-ci)) \
806810
fi
807811

812+
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
813+
VERSION=v$(RAWVER)
814+
808815
.PHONY: doc-only
809816
doc-only: tools/doc/node_modules \
810-
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
817+
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
811818
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
812-
echo "Skipping doc-only (no crypto and/or no ICU)"; \
819+
echo "Skipping doc-only (no crypto or no icu)"; \
813820
else \
814-
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
821+
$(MAKE) out/doc/api/all.html out/doc/api/all.json; \
815822
fi
816823

817824
.PHONY: doc
@@ -827,82 +834,37 @@ out/doc/api: doc/api
827834
mkdir -p $@
828835
cp -r doc/api out/doc
829836

830-
# If it's a source tarball, assets are already in doc/api/assets
831-
out/doc/api/assets:
832-
mkdir -p $@
833-
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
834-
835-
# If it's not a source tarball, we need to copy assets from doc/api_assets
836-
out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
837-
@cp $< $@ ; $(RM) out/doc/api/assets/README.md
838-
837+
# For generating individual doc files instead of all at once
838+
out/doc/api/%.html out/doc/api/%.json: doc/api/%.md tools/doc/node_modules | out/doc/api
839+
$(call available-node, \
840+
$(NPX) --prefix tools/doc api-docs-tooling generate \
841+
-t $(subst .,legacy-, $(suffix $@)) \
842+
-i $< \
843+
--ignore $(skip_apidoc_files) \
844+
-o $(@D) \
845+
--skip-lint \
846+
-c ./CHANGELOG.md \
847+
-v $(VERSION) \
848+
--index doc/api/index.md \
849+
) \
839850

840-
run-npm-ci = $(PWD)/$(NPM) ci
851+
out/doc/api/all.html: $(apidocs_html) | out/doc/api
841852

842-
LINK_DATA = out/doc/apilinks.json
843-
VERSIONS_DATA = out/previous-doc-versions.json
844-
gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
845-
--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
846-
--versions-file=$(VERSIONS_DATA)
847-
gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)
848-
849-
$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
850-
$(call available-node, $(gen-apilink))
851-
852-
# Regenerate previous versions data if the current version changes
853-
$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
854-
$(call available-node, tools/doc/versions.mjs $@)
855-
856-
node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
857-
858-
out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.mjs \
859-
tools/doc/markdown.mjs tools/doc/html.mjs tools/doc/json.mjs \
860-
tools/doc/apilinks.mjs $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api
861-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
862-
echo "Skipping documentation generation (no ICU)"; \
863-
else \
864-
$(call available-node, $(gen-api)) \
865-
fi
866-
867-
out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \
868-
tools/doc/apilinks.mjs | out/doc/api
869-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
870-
echo "Skipping HTML single-page doc generation (no ICU)"; \
871-
else \
872-
$(call available-node, tools/doc/allhtml.mjs) \
873-
fi
874-
875-
out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api
876-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
877-
echo "Skipping JSON single-file generation (no ICU)"; \
878-
else \
879-
$(call available-node, tools/doc/alljson.mjs) \
880-
fi
881-
882-
.PHONY: out/doc/api/stability
883-
out/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api
884-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
885-
echo "Skipping stability indicator generation (no ICU)"; \
886-
else \
887-
$(call available-node, tools/doc/stability.mjs) \
888-
fi
853+
out/doc/api/all.json: $(apidocs_json) | out/doc/api
889854

890855
.PHONY: docopen
891-
docopen: out/doc/api/all.html ## Open the documentation in a web browser.
856+
docopen: doc-only ## Open the documentation in a web browser.
892857
@$(PYTHON) -mwebbrowser file://$(abspath $<)
893858

894859
.PHONY: docserve
895-
docserve: $(apidocs_html) $(apiassets) ## Serve the documentation on localhost:8000.
860+
docserve: doc-only ## Serve the documentation on localhost:8000.
896861
@$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
897862

898863
.PHONY: docclean
899864
.NOTPARALLEL: docclean
900865
docclean: ## Remove the generated documentation.
901866
$(RM) -r out/doc
902-
$(RM) "$(VERSIONS_DATA)"
903867

904-
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
905-
VERSION=v$(RAWVER)
906868
CHANGELOG=doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER))).md
907869

908870
# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
@@ -1426,7 +1388,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
14261388
@touch $@
14271389

14281390
.PHONY: lint-md
1429-
lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1391+
lint-md: lint-js-doc lint-docs | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1392+
1393+
.PHONY: lint-docs
1394+
lint-docs: tools/doc/node_modules
1395+
$(info Running API Doc linter...)
1396+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling lint -i doc/api/*.md)
14301397

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

doc/api/synopsis.md

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)