Skip to content

Commit

Permalink
Generate API docs as part of Sphinx's build process
Browse files Browse the repository at this point in the history
This change has the benefit of supporting ReadTheDocs builds as
discussed in readthedocs/readthedocs.org#1139
  • Loading branch information
MarkusH committed Sep 30, 2020
1 parent 6db90c1 commit 288aa96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Generate and test API docs
run: |
make apidocs html
make html
env:
SPHINXOPTS: "-n -v -W --keep-going"
working-directory: ./docs
5 changes: 0 additions & 5 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ help:

.PHONY: help Makefile


apidocs:
git clean -fdx "$(SOURCEDIR)/ref"
sphinx-apidoc --ext-autodoc --ext-intersphinx --separate --implicit-namespaces --no-toc -o "$(SOURCEDIR)/ref" ../crate

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Expand Down
17 changes: 17 additions & 0 deletions docs/source/crate_operator_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
from sphinx.errors import NoUri


def run_apidoc(_):
from sphinx.ext import apidoc

argv = [
"--ext-autodoc",
"--ext-intersphinx",
"--separate",
"--implicit-namespaces",
"--no-toc",
"-o",
"source/ref",
"../crate",
]
apidoc.main(argv)


def missing_reference(
app: Sphinx, env: BuildEnvironment, node: pending_xref, contnode: Element
) -> Element:
Expand Down Expand Up @@ -49,4 +65,5 @@ def missing_reference(


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

0 comments on commit 288aa96

Please sign in to comment.