Skip to content
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

ReadTheDocs: enable automatic apidoc run/generation #33

Merged
merged 2 commits into from
Jun 4, 2021
Merged
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
15 changes: 2 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,9 @@ stylecheck:
.PHONY: checks
checks: typecheck stylecheck


.PHONY: genautodocs
genautodocs:
rm -rf docs/.generated
mkdir docs/.generated
sphinx-apidoc -f -o docs/.generated src/


.PHONY: docs
docs: genautodocs docs-noauto


.PHONY: docs-noauto
docs-noauto:
docs:
rm -rf docs/.generated
sphinx-build -W -b html docs docs/.build/

.PHONY: style
Expand Down
21 changes: 19 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

import sphinx_rtd_theme
from sphinx.ext.apidoc import main

needs_sphinx = '1.6'

Expand Down Expand Up @@ -34,15 +35,31 @@
autodoc_typehints = "description"


src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))
script_dir = os.path.normpath(os.path.dirname(__file__))
src_dir = os.path.abspath(os.path.join(script_dir, '../src'))

print(src_dir + "/")

sys.path.insert(0, src_dir)

import psi


intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}

# -- Setup for Sphinx API Docs -----------------------------------------------

# Workaround since sphinx does not automatically run apidoc before a build
# Copied from https://github.com/readthedocs/readthedocs.org/issues/1139

# run api doc
def run_apidoc(_):
output_path = os.path.join(script_dir, '.generated')
print(f"OUTPUT PATH = {output_path}")
#exclusions = [os.path.join(src_dir, 'setup.py'),]
main(['-f', '-o', output_path, src_dir])

# launch setup
def setup(app):
app.connect('builder-inited', run_apidoc)