Skip to content

Commit

Permalink
build, doc: use new api doc tooling
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
flakey5 and ovflowd committed Mar 6, 2025
1 parent e44ec42 commit 77ede22
Show file tree
Hide file tree
Showing 29 changed files with 1,499 additions and 7,420 deletions.
90 changes: 19 additions & 71 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ NODE_EXE = node$(EXEEXT)
NODE ?= "$(PWD)/$(NODE_EXE)"
NODE_G_EXE = node_g$(EXEEXT)
NPM ?= ./deps/npm/bin/npm-cli.js
NPX ?= ./deps/npm/bin/npx-cli.js

# Flags for packaging.
BUILD_DOWNLOAD_FLAGS ?= --download=all
Expand All @@ -105,6 +106,16 @@ available-node = \
exit 1; \
fi;

available-npx = \
if [ -x "$(NPX)" ] && [ -e "$(NPX)" ]; then \
"$(NPX)" $(1); \
elif [ -x `command -v npx` ] && [ -e `command -v npx` ] && [ `command -v npx` ]; then \
`command -v npx` $(1); \
else \
echo "No available npx, cannot run \"npx $(1)\""; \
exit 1; \
fi;

.PHONY: all
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
Expand Down Expand Up @@ -363,7 +374,7 @@ test-valgrind: all
test-check-deopts: all
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential

DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
DOCBUILDSTAMP_PREREQS = tools/doc/ doc/api/addons.md

ifeq ($(OSTYPE),aix)
DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
Expand All @@ -379,7 +390,7 @@ test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
echo "Skipping .docbuildstamp (no crypto)"; \
else \
$(RM) -r test/addons/??_*/; \
[ -x $(NODE) ] && $(NODE) $< || node $< ; \
[ -x $(NPM) ] && $(NPM) --prefix $< run addon-verify || npm --prefix $< run addon-verify ; \
[ $$? -eq 0 ] && touch $@; \
fi

Expand Down Expand Up @@ -740,11 +751,8 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
endif

apidoc_dirs = out/doc out/doc/api out/doc/api/assets
apidoc_sources = $(wildcard doc/api/*.md)
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))

apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
run-npm-ci = $(PWD)/$(NPM) ci

tools/doc/node_modules: tools/doc/package.json
@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
Expand All @@ -755,11 +763,11 @@ tools/doc/node_modules: tools/doc/package.json

.PHONY: doc-only
doc-only: tools/doc/node_modules \
$(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
echo "Skipping doc-only (no crypto)"; \
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
@if [ "$(shell $(node_use_openssl))" != "true" ] || [ "$(shell $(node_use_icu))" != "true" ]; then \
echo "Skipping doc-only (no crypto or no icu)"; \
else \
$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
$(call available-npx, --prefix tools/doc api-docs-tooling -t legacy-html-all legacy-json-all api-links -i doc/api/\*.md -i lib/\*.js -o out/doc/api/ -c file://$(PWD)/CHANGELOG.md) \
fi

.PHONY: doc
Expand All @@ -774,66 +782,6 @@ out/doc/api: doc/api
mkdir -p $@
cp -r doc/api out/doc

# If it's a source tarball, assets are already in doc/api/assets
out/doc/api/assets:
mkdir -p $@
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;

# If it's not a source tarball, we need to copy assets from doc/api_assets
out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
@cp $< $@ ; $(RM) out/doc/api/assets/README.md


run-npm-ci = $(PWD)/$(NPM) ci

LINK_DATA = out/doc/apilinks.json
VERSIONS_DATA = out/previous-doc-versions.json
gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
--versions-file=$(VERSIONS_DATA)
gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)

$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
$(call available-node, $(gen-apilink))

# Regenerate previous versions data if the current version changes
$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
$(call available-node, tools/doc/versions.mjs $@)

node_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")

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

out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \
tools/doc/apilinks.mjs | out/doc/api
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
echo "Skipping HTML single-page doc generation (no ICU)"; \
else \
$(call available-node, tools/doc/allhtml.mjs) \
fi

out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
echo "Skipping JSON single-file generation (no ICU)"; \
else \
$(call available-node, tools/doc/alljson.mjs) \
fi

.PHONY: out/doc/api/stability
out/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api
@if [ "$(shell $(node_use_icu))" != "true" ]; then \
echo "Skipping stability indicator generation (no ICU)"; \
else \
$(call available-node, tools/doc/stability.mjs) \
fi

.PHONY: docopen
docopen: out/doc/api/all.html
@$(PYTHON) -mwebbrowser file://$(abspath $<)
Expand Down
13 changes: 0 additions & 13 deletions doc/api_assets/README.md

This file was deleted.

212 changes: 0 additions & 212 deletions doc/api_assets/api.js

This file was deleted.

Loading

0 comments on commit 77ede22

Please sign in to comment.