Skip to content

build, doc: use new api doc tooling #57343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
/onboarding.md @nodejs/tsc

# nodejs.org website
/doc/api_assets @nodejs/nodejs-website
/doc/template.html @nodejs/nodejs-website
/tools/doc @nodejs/web-infra

# streams
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ concurrency:
cancel-in-progress: true

env:
NODE_VERSION: lts/*
PYTHON_VERSION: '3.12'
FLAKY_TESTS: keep_retrying
CC: sccache clang
Expand All @@ -45,6 +46,10 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: ${{ env.NODE_VERSION }}
Comment on lines +49 to +52
Copy link
Contributor

@aduh95 aduh95 May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this, we should be able to build node without node (it's probably related to #57343 (comment), no?)

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
Expand Down Expand Up @@ -75,6 +80,10 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,7 @@ jobs:
label: tools
run: |
cd tools/doc
npm ci
NEW_VERSION=$(npm outdated --parseable | cut -d: -f4 | xargs)
if [ "$NEW_VERSION" != "" ]; then
echo "NEW_VERSION=new version" >> $GITHUB_ENV
rm -rf package-lock.json node_modules
# Include $NEW_VERSION to explicitly update the package.json
# entry for the dependency and also so that semver-major updates
# are not skipped.
npm install --ignore-scripts $NEW_VERSION
npm install --ignore-scripts
fi
./update.sh
- id: googletest
subsystem: deps
label: dependencies, test
Expand Down
107 changes: 32 additions & 75 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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 Down Expand Up @@ -333,7 +334,6 @@ coverage-run-js: ## Run JavaScript tests with coverage.
# This does not run tests of third-party libraries inside deps.
test: all ## Run default tests, linters, and build docs.
$(MAKE) -s tooltest
$(MAKE) -s test-doc
$(MAKE) -s build-addons
$(MAKE) -s build-js-native-api-tests
$(MAKE) -s build-node-api-tests
Expand Down Expand Up @@ -369,7 +369,7 @@ test-valgrind: all ## Run tests using valgrind.
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 = doc/api/addons.md

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

Expand Down Expand Up @@ -779,14 +779,10 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
endif

apidoc_dirs = out/doc out/doc/api out/doc/api/assets
apidoc_dirs = out/doc out/doc/api
skip_apidoc_files = doc/api/quic.md

apidoc_sources = $(filter-out $(skip_apidoc_files), $(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/*)))
run-npm-ci = $(PWD)/$(NPM) ci

tools/doc/node_modules: tools/doc/package.json
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
Expand All @@ -795,13 +791,26 @@ tools/doc/node_modules: tools/doc/package.json
cd tools/doc && $(call available-node,$(run-npm-ci)) \
fi

RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
VERSION=v$(RAWVER)

.PHONY: doc-only
doc-only: tools/doc/node_modules \
$(apidoc_dirs) $(apiassets) ## Build the docs with the local or the global Node.js binary.
$(apidoc_dirs) ## Builds the docs with the local or the global Node.js binary.
@if [ "$(shell $(node_use_openssl_and_icu))" != "true" ]; then \
echo "Skipping doc-only (no crypto and/or no ICU)"; \
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-node, \
$(NPX) --prefix tools/doc api-docs-tooling generate \
-t legacy-html-all legacy-json-all api-links \
-i doc/api/*.md \
-i lib/*.js \
--ignore $(skip_apidoc_files) \
-o out/doc/api/ \
--no-lint \
-c file://$(PWD)/CHANGELOG.md \
-v $(VERSION) \
) \
fi

.PHONY: doc
Expand All @@ -817,82 +826,25 @@ 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
out/doc/api/%.json out/doc/api/%.html: doc-only

out/doc/api/all.html: doc-only

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
out/doc/api/all.json: doc-only

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

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

.PHONY: docclean
.NOTPARALLEL: docclean
docclean: ## Remove the generated documentation.
$(RM) -r out/doc
$(RM) "$(VERSIONS_DATA)"

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

# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
Expand Down Expand Up @@ -1396,7 +1348,12 @@ tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_
@touch $@

.PHONY: lint-md
lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.
lint-md: lint-js-doc lint-docs | tools/.mdlintstamp ## Lint the markdown documents maintained by us in the codebase.

.PHONY: lint-docs
lint-docs: tools/doc/node_modules
$(info Running API Doc linter...)
$(call available-node, $(NPX) --prefix tools/doc api-docs-tooling lint -i doc/api/*.md)

run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
.PHONY: format-md
Expand Down
4 changes: 2 additions & 2 deletions doc/api/synopsis.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Usage and example

## Usage

<!--introduced_in=v0.10.0-->

<!--type=misc-->

## Usage

`node [options] [V8 options] [script.js | -e "script" | - ] [arguments]`

Please see the [Command-line options][] document for more information.
Expand Down
7 changes: 0 additions & 7 deletions doc/api_assets/README.md

This file was deleted.

Loading
Loading