Skip to content

Commit 9188347

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 3f8ced6 commit 9188347

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.github/workflows/lint.yaml

+1-1
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

-5
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

+19
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,31 @@
1414
# You should have received a copy of the GNU Affero General Public License
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17+
import pathlib
18+
1719
from docutils.nodes import Element
1820
from sphinx.addnodes import pending_xref
1921
from sphinx.application import Sphinx
2022
from sphinx.environment import BuildEnvironment
2123
from sphinx.errors import NoUri
2224

2325

26+
def run_apidoc(_):
27+
from sphinx.ext import apidoc
28+
29+
argv = [
30+
"--ext-autodoc",
31+
"--ext-intersphinx",
32+
"--separate",
33+
"--implicit-namespaces",
34+
"--no-toc",
35+
"-o",
36+
str(pathlib.Path(__file__).parent / "ref"),
37+
str(pathlib.Path(__file__).parent.parent.parent / "crate"),
38+
]
39+
apidoc.main(argv)
40+
41+
2442
def missing_reference(
2543
app: Sphinx, env: BuildEnvironment, node: pending_xref, contnode: Element
2644
) -> Element:
@@ -49,4 +67,5 @@ def missing_reference(
4967

5068

5169
def setup(app):
70+
app.connect("builder-inited", run_apidoc)
5271
app.connect("missing-reference", missing_reference)

0 commit comments

Comments
 (0)