Skip to content

Commit 0702f56

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 a430ef5 commit 0702f56

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

+1830
-5350
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
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/tools.yml

Lines changed: 1 addition & 11 deletions
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

Lines changed: 48 additions & 75 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
@@ -82,6 +86,7 @@ NODE_EXE = node$(EXEEXT)
8286
NODE ?= "$(PWD)/$(NODE_EXE)"
8387
NODE_G_EXE = node_g$(EXEEXT)
8488
NPM ?= ./deps/npm/bin/npm-cli.js
89+
NPX ?= ./deps/npm/bin/npx-cli.js
8590

8691
# Flags for packaging.
8792
BUILD_DOWNLOAD_FLAGS ?= --download=all
@@ -333,7 +338,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
333338
# This does not run tests of third-party libraries inside deps.
334339
test: all ## Run default tests, linters, and build docs.
335340
$(MAKE) -s tooltest
336-
$(MAKE) -s test-doc
337341
$(MAKE) -s build-addons
338342
$(MAKE) -s build-js-native-api-tests
339343
$(MAKE) -s build-node-api-tests
@@ -369,7 +373,7 @@ test-valgrind: all ## Run tests using valgrind.
369373
test-check-deopts: all
370374
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
371375

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

374378
ifeq ($(OSTYPE),aix)
375379
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
@@ -385,7 +389,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
385389
echo "Skipping .docbuildstamp (no crypto and/or no ICU)"; \
386390
else \
387391
$(RM) -r test/addons/??_*/; \
388-
[ -x $(NODE) ] && $(NODE) $< || node $< ; \
392+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling generate -t addon-verify -i doc/api/addons.md -o test/addons/ --no-lint) \
389393
[ $$? -eq 0 ] && touch $@; \
390394
fi
391395

@@ -781,14 +785,10 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
781785
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
782786
endif
783787

784-
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
788+
apidoc_dirs = out/doc out/doc/api
785789
skip_apidoc_files = doc/api/quic.md
786790

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

793793
tools/doc/node_modules: tools/doc/package.json
794794
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
@@ -797,13 +797,27 @@ tools/doc/node_modules: tools/doc/package.json
797797
cd tools/doc && $(call available-node,$(run-npm-ci)) \
798798
fi
799799

800+
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
801+
VERSION=v$(RAWVER)
802+
800803
.PHONY: doc-only
801804
doc-only: tools/doc/node_modules \
802-
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
805+
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
803806
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
804-
echo "Skipping doc-only (no crypto and/or no ICU)"; \
807+
echo "Skipping doc-only (no crypto or no icu)"; \
805808
else \
806-
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
809+
$(call available-node, \
810+
$(NPX) --prefix tools/doc api-docs-tooling generate \
811+
-t legacy-html-all legacy-json-all api-links \
812+
-i doc/api/*.md \
813+
-i lib/*.js \
814+
--ignore $(skip_apidoc_files) \
815+
-o out/doc/api/ \
816+
--no-lint \
817+
-c ./CHANGELOG.md \
818+
-v $(VERSION) \
819+
-p $(DOC_JOBS) \
820+
) \
807821
fi
808822

809823
.PHONY: doc
@@ -819,82 +833,36 @@ out/doc/api: doc/api
819833
mkdir -p $@
820834
cp -r doc/api out/doc
821835

822-
# If it's a source tarball, assets are already in doc/api/assets
823-
out/doc/api/assets:
824-
mkdir -p $@
825-
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
826-
827-
# If it's not a source tarball, we need to copy assets from doc/api_assets
828-
out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
829-
@cp $< $@ ; $(RM) out/doc/api/assets/README.md
830-
831-
832-
run-npm-ci = $(PWD)/$(NPM) ci
833-
834-
LINK_DATA = out/doc/apilinks.json
835-
VERSIONS_DATA = out/previous-doc-versions.json
836-
gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
837-
--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
838-
--versions-file=$(VERSIONS_DATA)
839-
gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)
840-
841-
$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
842-
$(call available-node, $(gen-apilink))
843-
844-
# Regenerate previous versions data if the current version changes
845-
$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
846-
$(call available-node, tools/doc/versions.mjs $@)
847-
848-
node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
836+
# For generating individual doc files instead of all at once
837+
out/doc/api/%.html out/doc/api/%.json: doc/api/%.md tools/doc/node_modules | out/doc/api
838+
$(call available-node, \
839+
$(NPX) --prefix tools/doc api-docs-tooling generate \
840+
-t $(subst .,legacy-, $(suffix $@)) \
841+
-i $< \
842+
-i lib/*.js \
843+
--ignore $(skip_apidoc_files) \
844+
-o $(@D) \
845+
--no-lint \
846+
-c ./CHANGELOG.md \
847+
-v $(VERSION) \
848+
) \
849849

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

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

882853
.PHONY: docopen
883-
docopen: out/doc/api/all.html ## Open the documentation in a web browser.
854+
docopen: doc-only ## Open the documentation in a web browser.
884855
@$(PYTHON) -mwebbrowser file://$(abspath $<)
885856

886857
.PHONY: docserve
887-
docserve: $(apidocs_html) $(apiassets) ## Serve the documentation on localhost:8000.
858+
docserve: doc-only ## Serve the documentation on localhost:8000.
888859
@$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
889860

890861
.PHONY: docclean
891862
.NOTPARALLEL: docclean
892863
docclean: ## Remove the generated documentation.
893864
$(RM) -r out/doc
894-
$(RM) "$(VERSIONS_DATA)"
895865

896-
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
897-
VERSION=v$(RAWVER)
898866
CHANGELOG=doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER))).md
899867

900868
# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
@@ -1390,7 +1358,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
13901358
@touch $@
13911359

13921360
.PHONY: lint-md
1393-
lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1361+
lint-md: lint-js-doc lint-docs | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
1362+
1363+
.PHONY: lint-docs
1364+
lint-docs: tools/doc/node_modules
1365+
$(info Running API Doc linter...)
1366+
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling lint -i doc/api/*.md)
13941367

13951368
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
13961369
.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)