Skip to content

Commit fa60b3b

Browse files
flakey5ovflowdavivkelleraduh95joyeecheung
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 <73616808+flakey5@users.noreply.github.com> Co-authored-by: Claudio W <cwunder@gnome.org> Co-authored-by: avivkeller <me@aviv.sh> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 1ad04e2 commit fa60b3b

Some content is hidden

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

43 files changed

+5153
-5360
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
@@ -119,6 +119,12 @@ jobs:
119119
run: |
120120
make corepack-update
121121
echo "NEW_VERSION=$(node deps/corepack/dist/corepack.js --version)" >> $GITHUB_ENV
122+
- id: doc
123+
subsystem: tools
124+
label: tools
125+
run: |
126+
cd tools/doc
127+
./update.sh
122128
- id: googletest
123129
subsystem: deps
124130
label: dependencies, test

Makefile

Lines changed: 44 additions & 74 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
@@ -101,7 +105,7 @@ V ?= 0
101105
# Use -e to double check in case it's a broken link
102106
available-node = \
103107
if [ -x '$(NODE)' ] && [ -e '$(NODE)' ]; then \
104-
'$(NODE)' $(1); \
108+
PATH='$(PWD)/out/$(BUILDTYPE):$$PATH' '$(NODE)' $(1); \
105109
elif [ -x `command -v node` ] && [ -e `command -v node` ] && [ `command -v node` ]; then \
106110
`command -v node` $(1); \
107111
else \
@@ -340,7 +344,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
340344
# This does not run tests of third-party libraries inside deps.
341345
test: all ## Run default tests, linters, and build docs.
342346
$(MAKE) -s tooltest
343-
$(MAKE) -s test-doc
344347
$(MAKE) -s build-addons
345348
$(MAKE) -s build-js-native-api-tests
346349
$(MAKE) -s build-node-api-tests
@@ -376,7 +379,7 @@ test-valgrind: all ## Run tests using valgrind.
376379
test-check-deopts: all
377380
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
378381

379-
DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
382+
DOCBUILDSTAMP_PREREQS = doc/api/addons.md
380383

381384
ifeq ($(OSTYPE),aix)
382385
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
@@ -385,14 +388,16 @@ ifeq ($(OSTYPE),os400)
385388
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
386389
endif
387390

391+
DOC_KIT ?= tools/doc/node_modules/.bin/doc-kit
392+
388393
node_use_openssl_and_icu = $(call available-node,"-p" \
389394
"process.versions.openssl != undefined && process.versions.icu != undefined")
390395
test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
391396
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
392397
echo "Skipping .docbuildstamp (no crypto and/or no ICU)"; \
393398
else \
394399
$(RM) -r test/addons/??_*/; \
395-
[ -x '$(NODE)' ] && '$(NODE)' $< || node $< ; \
400+
$(call available-node, $(DOC_KIT) generate -t addon-verify -i doc/api/addons.md -o test/addons/ --type-map doc/type-map.json) \
396401
[ $$? -eq 0 ] && touch $@; \
397402
fi
398403

@@ -791,29 +796,30 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
791796
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
792797
endif
793798

794-
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
799+
apidoc_dirs = out/doc out/doc/api
795800
skip_apidoc_files = doc/api/quic.md
796801

797802
apidoc_sources = $(filter-out $(skip_apidoc_files), $(wildcard doc/api/*.md))
798803
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
799804
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
800805

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

803808
tools/doc/node_modules: tools/doc/package.json
804-
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
809+
if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
805810
echo "Skipping tools/doc/node_modules (no crypto and/or no ICU)"; \
806811
else \
807812
cd tools/doc && $(call available-node,$(run-npm-ci)) \
808813
fi
809814

815+
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
816+
VERSION=v$(RAWVER)
817+
810818
.PHONY: doc-only
811819
doc-only: tools/doc/node_modules \
812-
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
820+
$(apidoc_dirs) $(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json out/doc/apilinks.json ## Builds the docs with the local or the global Node.js binary.
813821
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
814-
echo "Skipping doc-only (no crypto and/or no ICU)"; \
815-
else \
816-
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
822+
echo "Skipping doc-only (no crypto or no icu)"; \
817823
fi
818824

819825
.PHONY: doc
@@ -829,82 +835,46 @@ out/doc/api: doc/api
829835
mkdir -p $@
830836
cp -r doc/api out/doc
831837

832-
# If it's a source tarball, assets are already in doc/api/assets
833-
out/doc/api/assets:
834-
mkdir -p $@
835-
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
836-
837-
# If it's not a source tarball, we need to copy assets from doc/api_assets
838-
out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
839-
@cp $< $@ ; $(RM) out/doc/api/assets/README.md
840-
841-
842-
run-npm-ci = '$(PWD)/$(NPM)' ci
843-
844-
LINK_DATA = out/doc/apilinks.json
845-
VERSIONS_DATA = out/previous-doc-versions.json
846-
gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
847-
--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
848-
--versions-file=$(VERSIONS_DATA)
849-
gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)
850-
851-
$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
852-
$(call available-node, $(gen-apilink))
853-
854-
# Regenerate previous versions data if the current version changes
855-
$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
856-
$(call available-node, tools/doc/versions.mjs $@)
857-
858-
node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
859-
860-
out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.mjs \
861-
tools/doc/markdown.mjs tools/doc/html.mjs tools/doc/json.mjs \
862-
tools/doc/apilinks.mjs $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api
863-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
864-
echo "Skipping documentation generation (no ICU)"; \
865-
else \
866-
$(call available-node, $(gen-api)) \
867-
fi
868-
869-
out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \
870-
tools/doc/apilinks.mjs | out/doc/api
871-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
872-
echo "Skipping HTML single-page doc generation (no ICU)"; \
873-
else \
874-
$(call available-node, tools/doc/allhtml.mjs) \
875-
fi
876-
877-
out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api
878-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
879-
echo "Skipping JSON single-file generation (no ICU)"; \
880-
else \
881-
$(call available-node, tools/doc/alljson.mjs) \
882-
fi
838+
# Generate all doc files (individual and all.html/all.json) in a single doc-kit call
839+
# Using grouped targets (&:) so Make knows one command produces all outputs
840+
$(apidocs_html) $(apidocs_json) out/doc/api/all.html out/doc/api/all.json &: $(apidoc_sources) tools/doc/node_modules | out/doc/api
841+
$(call available-node, \
842+
$(DOC_KIT) generate \
843+
-t legacy-html-all \
844+
-t legacy-json-all \
845+
-i doc/api/*.md \
846+
--ignore $(skip_apidoc_files) \
847+
-o out/doc/api \
848+
-c ./CHANGELOG.md \
849+
-v $(VERSION) \
850+
--index doc/api/index.md \
851+
--type-map doc/type-map.json \
852+
)
883853

884-
.PHONY: out/doc/api/stability
885-
out/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api
886-
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
887-
echo "Skipping stability indicator generation (no ICU)"; \
888-
else \
889-
$(call available-node, tools/doc/stability.mjs) \
890-
fi
854+
out/doc/apilinks.json: $(wildcard lib/*.js) | out/doc
855+
$(call available-node, \
856+
$(DOC_KIT) generate \
857+
-t api-links \
858+
-i lib/*.js \
859+
-o $(@D) \
860+
-c ./CHANGELOG.md \
861+
-v $(VERSION) \
862+
--type-map doc/type-map.json \
863+
) \
891864

892865
.PHONY: docopen
893-
docopen: out/doc/api/all.html ## Open the documentation in a web browser.
866+
docopen: doc-only ## Open the documentation in a web browser.
894867
@$(PYTHON) -mwebbrowser file://$(abspath $<)
895868

896869
.PHONY: docserve
897-
docserve: $(apidocs_html) $(apiassets) ## Serve the documentation on localhost:8000.
870+
docserve: doc-only ## Serve the documentation on localhost:8000.
898871
@$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
899872

900873
.PHONY: docclean
901874
.NOTPARALLEL: docclean
902875
docclean: ## Remove the generated documentation.
903876
$(RM) -r out/doc
904-
$(RM) "$(VERSIONS_DATA)"
905877

906-
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
907-
VERSION=v$(RAWVER)
908878
CHANGELOG=doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER))).md
909879

910880
# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or

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)