@@ -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/ --skip-lint) \
389
393
[ $$ ? -eq 0 ] && touch $@ ; \
390
394
fi
391
395
@@ -781,14 +785,14 @@ 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
791
apidoc_sources = $(filter-out $(skip_apidoc_files ) , $(wildcard doc/api/* .md) )
788
792
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html ) )
789
793
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json ) )
790
794
791
- apiassets = $(subst api_assets,api/assets, $( addprefix out/, $( wildcard doc/api_assets/ * ) ) )
795
+ run-npm-ci = $(PWD ) / $( NPM ) ci --omit=dev
792
796
793
797
tools/doc/node_modules : tools/doc/package.json
794
798
@if [ " $( shell $( node_use_openssl_and_icu) ) " != " true" ]; then \
@@ -797,13 +801,16 @@ tools/doc/node_modules: tools/doc/package.json
797
801
cd tools/doc && $(call available-node,$(run-npm-ci ) ) \
798
802
fi
799
803
804
+ RAWVER =$(shell $(PYTHON ) tools/getnodeversion.py)
805
+ VERSION =v$(RAWVER )
806
+
800
807
.PHONY : doc-only
801
808
doc-only : tools/doc/node_modules \
802
- $(apidoc_dirs ) $( apiassets ) # # Build the docs with the local or the global Node.js binary.
809
+ $(apidoc_dirs ) # # Builds the docs with the local or the global Node.js binary.
803
810
@if [ " $( shell $( node_use_openssl_and_icu) ) " != " true" ]; then \
804
- echo " Skipping doc-only (no crypto and/ or no ICU )" ; \
811
+ echo " Skipping doc-only (no crypto or no icu )" ; \
805
812
else \
806
- $(MAKE ) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability ; \
813
+ $(MAKE ) out/doc/api/all.html out/doc/api/all.json
807
814
fi
808
815
809
816
.PHONY : doc
@@ -819,82 +826,37 @@ out/doc/api: doc/api
819
826
mkdir -p $@
820
827
cp -r doc/api out/doc
821
828
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
-
829
+ # For generating individual doc files instead of all at once
830
+ out/doc/api/% .html out/doc/api/% .json : doc/api/% .md tools/doc/node_modules | out/doc/api
831
+ $(call available-node, \
832
+ $(NPX ) --prefix tools/doc api-docs-tooling generate \
833
+ -t $(subst .,legacy-, $(suffix $@ ) ) \
834
+ -i $< \
835
+ --ignore $(skip_apidoc_files ) \
836
+ -o $(@D ) \
837
+ --skip-lint \
838
+ -c ./CHANGELOG.md \
839
+ -v $(VERSION ) \
840
+ --index doc/api/index.md \
841
+ ) \
831
842
832
- run-npm-ci = $( PWD ) / $( NPM ) ci
843
+ out/doc/api/all.html : $( apidocs_html ) | out/doc/api
833
844
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'")
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
-
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
845
+ out/doc/api/all.json : $(apidocs_json ) | out/doc/api
881
846
882
847
.PHONY : docopen
883
- docopen : out/ doc/api/all.html # # Open the documentation in a web browser.
848
+ docopen : doc-only # # Open the documentation in a web browser.
884
849
@$(PYTHON ) -mwebbrowser file://$(abspath $< )
885
850
886
851
.PHONY : docserve
887
- docserve : $( apidocs_html ) $( apiassets ) # # Serve the documentation on localhost:8000.
852
+ docserve : doc-only # # Serve the documentation on localhost:8000.
888
853
@$(PYTHON ) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
889
854
890
855
.PHONY : docclean
891
856
.NOTPARALLEL : docclean
892
857
docclean : # # Remove the generated documentation.
893
858
$(RM ) -r out/doc
894
- $(RM ) " $( VERSIONS_DATA) "
895
859
896
- RAWVER =$(shell $(PYTHON ) tools/getnodeversion.py)
897
- VERSION =v$(RAWVER )
898
860
CHANGELOG =doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER ) ) ) .md
899
861
900
862
# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
@@ -1390,7 +1352,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
1390
1352
@touch $@
1391
1353
1392
1354
.PHONY : lint-md
1393
- lint-md : lint-js-doc | tools/.mdlintstamp # # Lint the markdown documents maintained by us in the codebase.
1355
+ lint-md : lint-js-doc lint-docs | tools/.mdlintstamp # # Lint the markdown documents maintained by us in the codebase.
1356
+
1357
+ .PHONY : lint-docs
1358
+ lint-docs : tools/doc/node_modules
1359
+ $(info Running API Doc linter...)
1360
+ $(call available-node, $(NPX ) --prefix tools/doc api-docs-tooling lint -i doc/api/* .md)
1394
1361
1395
1362
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES )
1396
1363
.PHONY : format-md
0 commit comments