@@ -26,8 +26,12 @@ FIND ?= find
26
26
27
27
ifdef JOBS
28
28
PARALLEL_ARGS = -j $(JOBS)
29
+
30
+ # Amount of worker threads to create for generating documentation files
31
+ DOC_JOBS = $(JOBS)
29
32
else
30
33
PARALLEL_ARGS =
34
+ DOC_JOBS = 12
31
35
endif
32
36
33
37
ifdef ENABLE_V8_TAP
@@ -82,6 +86,7 @@ NODE_EXE = node$(EXEEXT)
82
86
NODE ?= "$(PWD ) /$(NODE_EXE ) "
83
87
NODE_G_EXE = node_g$(EXEEXT )
84
88
NPM ?= ./deps/npm/bin/npm-cli.js
89
+ NPX ?= ./deps/npm/bin/npx-cli.js
85
90
86
91
# Flags for packaging.
87
92
BUILD_DOWNLOAD_FLAGS ?= --download=all
@@ -333,7 +338,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
333
338
# This does not run tests of third-party libraries inside deps.
334
339
test : all # # Run default tests, linters, and build docs.
335
340
$(MAKE ) -s tooltest
336
- $(MAKE ) -s test-doc
337
341
$(MAKE ) -s build-addons
338
342
$(MAKE ) -s build-js-native-api-tests
339
343
$(MAKE ) -s build-node-api-tests
@@ -369,7 +373,7 @@ test-valgrind: all ## Run tests using valgrind.
369
373
test-check-deopts : all
370
374
$(PYTHON ) tools/test.py $(PARALLEL_ARGS ) --mode=$(BUILDTYPE_LOWER ) --check-deopts parallel sequential
371
375
372
- DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
376
+ DOCBUILDSTAMP_PREREQS = doc/api/addons.md
373
377
374
378
ifeq ($(OSTYPE ) ,aix)
375
379
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS ) out/$(BUILDTYPE ) /node.exp
@@ -385,7 +389,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
385
389
echo " Skipping .docbuildstamp (no crypto and/or no ICU)" ; \
386
390
else \
387
391
$(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) \
389
393
[ $$ ? -eq 0 ] && touch $@ ; \
390
394
fi
391
395
@@ -781,14 +785,10 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
781
785
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
782
786
endif
783
787
784
- apidoc_dirs = out/doc out/doc/api out/doc/api/assets
788
+ apidoc_dirs = out/doc out/doc/api
785
789
skip_apidoc_files = doc/api/quic.md
786
790
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
792
792
793
793
tools/doc/node_modules : tools/doc/package.json
794
794
@if [ " $( shell $( node_use_openssl_and_icu) ) " != " true" ]; then \
@@ -797,13 +797,27 @@ tools/doc/node_modules: tools/doc/package.json
797
797
cd tools/doc && $(call available-node,$(run-npm-ci ) ) \
798
798
fi
799
799
800
+ RAWVER =$(shell $(PYTHON ) tools/getnodeversion.py)
801
+ VERSION =v$(RAWVER )
802
+
800
803
.PHONY : doc-only
801
804
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.
803
806
@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 )" ; \
805
808
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
+ ) \
807
821
fi
808
822
809
823
.PHONY : doc
@@ -819,82 +833,36 @@ out/doc/api: doc/api
819
833
mkdir -p $@
820
834
cp -r doc/api out/doc
821
835
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
+ ) \
849
849
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
858
850
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
881
852
882
853
.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.
884
855
@$(PYTHON ) -mwebbrowser file://$(abspath $< )
885
856
886
857
.PHONY : docserve
887
- docserve : $( apidocs_html ) $( apiassets ) # # Serve the documentation on localhost:8000.
858
+ docserve : doc-only # # Serve the documentation on localhost:8000.
888
859
@$(PYTHON ) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
889
860
890
861
.PHONY : docclean
891
862
.NOTPARALLEL : docclean
892
863
docclean : # # Remove the generated documentation.
893
864
$(RM ) -r out/doc
894
- $(RM ) " $( VERSIONS_DATA) "
895
865
896
- RAWVER =$(shell $(PYTHON ) tools/getnodeversion.py)
897
- VERSION =v$(RAWVER )
898
866
CHANGELOG =doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER ) ) ) .md
899
867
900
868
# 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_
1390
1358
@touch $@
1391
1359
1392
1360
.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)
1394
1367
1395
1368
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES )
1396
1369
.PHONY : format-md
0 commit comments