Skip to content

Commit 7d1805b

Browse files
authored
build: add render-api-index make target (#43)
- Regenerates docs/src/api/index.md via the standalone generator without the full `make docs` Sphinx build - Runs under the base dev env, so refreshing the API index no longer requires the docs environment or its toolchain
1 parent 2965864 commit 7d1805b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Use of this source code is governed by a BSD-3-Clause license that can
44
# be found in the LICENSE file or at https://opensource.org/licenses/BSD-3-Clause
55

6-
.PHONY: _maybe_patch_pyproject all api-list build check clean distclean distclean-all docs docs-clean docs-open env env-all env-docs env-highest-torch env-tutorial set-auto-venv test test-cov test-fast test-highest-pytorch test-lowest-pytorch test-slow test-smoke test-tutorials version
6+
.PHONY: _maybe_patch_pyproject all api-list build check clean distclean distclean-all docs docs-clean docs-open env env-all env-docs env-highest-torch env-tutorial render-api-index set-auto-venv test test-cov test-fast test-highest-pytorch test-lowest-pytorch test-slow test-smoke test-tutorials version
77

88
SHELL := /bin/bash
99

@@ -331,6 +331,13 @@ endif
331331
docs-clean:
332332
@rm -rf $(DOCS_DIR)/build $(DOCS_DIR)/src/api/generated
333333

334+
# Regenerate docs/src/api/index.md from the package tree.
335+
#
336+
# Runs the same generator `make docs` invokes during the Sphinx build, so the
337+
# API index can be refreshed on its own using the base dev env.
338+
render-api-index:
339+
@$(call use_env,VENV) && uv run --no-sync --active python $(MAKEFILE_DIR)docs/scripts/generate_api_index.py
340+
334341
# Build and open documentation in browser
335342
# Uses --serve so the docs are loaded over HTTP, not file:// — required for
336343
# the Copy page button (and any other feature using fetch()/clipboard APIs).

docs/scripts/generate_api_index.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def generate_api_index() -> str:
162162

163163

164164
if __name__ == "__main__":
165-
repo_root = find_repo_root(__file__)
165+
# Anchor on the cwd so `make` writes the invoking repo's index.
166+
repo_root = find_repo_root()
166167
output = repo_root / _OUTPUT_PATH
167168

168169
content = generate_api_index()

0 commit comments

Comments
 (0)