Skip to content

Commit 288aa96

Browse files
committed
Generate API docs as part of Sphinx's build process
This change has the benefit of supporting ReadTheDocs builds as discussed in readthedocs/readthedocs.org#1139
1 parent 6db90c1 commit 288aa96

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
4848
- name: Generate and test API docs
4949
run: |
50-
make apidocs html
50+
make html
5151
env:
5252
SPHINXOPTS: "-n -v -W --keep-going"
5353
working-directory: ./docs

docs/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ help:
1414

1515
.PHONY: help Makefile
1616

17-
18-
apidocs:
19-
git clean -fdx "$(SOURCEDIR)/ref"
20-
sphinx-apidoc --ext-autodoc --ext-intersphinx --separate --implicit-namespaces --no-toc -o "$(SOURCEDIR)/ref" ../crate
21-
2217
# Catch-all target: route all unknown targets to Sphinx using the new
2318
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2419
%: Makefile

docs/source/crate_operator_ext.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
from sphinx.errors import NoUri
2222

2323

24+
def run_apidoc(_):
25+
from sphinx.ext import apidoc
26+
27+
argv = [
28+
"--ext-autodoc",
29+
"--ext-intersphinx",
30+
"--separate",
31+
"--implicit-namespaces",
32+
"--no-toc",
33+
"-o",
34+
"source/ref",
35+
"../crate",
36+
]
37+
apidoc.main(argv)
38+
39+
2440
def missing_reference(
2541
app: Sphinx, env: BuildEnvironment, node: pending_xref, contnode: Element
2642
) -> Element:
@@ -49,4 +65,5 @@ def missing_reference(
4965

5066

5167
def setup(app):
68+
app.connect("builder-inited", run_apidoc)
5269
app.connect("missing-reference", missing_reference)

0 commit comments

Comments
 (0)