Skip to content

Commit

Permalink
Merge pull request #1336 from gizmoguy/sphinx-docs-port
Browse files Browse the repository at this point in the history
Run sphinx-apidoc as part of conf.py so it works on readthedocs.
  • Loading branch information
gizmoguy committed Dec 2, 2017
2 parents c61cdb8 + 8a469c3 commit 5a5522e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 0 additions & 5 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

# You can set these variables from the command line.
SPHINXOPTS =
APIDOC = sphinx-apidoc
APIDOCOUTPUT = source/apidoc
APIDOCMODPATH = ../faucet
APIDOCEXCLUDE =
SPHINXBUILD = sphinx-build
SPHINXPROJ = faucet
SOURCEDIR = .
Expand All @@ -21,5 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(APIDOC) -o $(APIDOCOUTPUT) $(APIDOCMODPATH) $(APIDOCEXCLUDE)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 15 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,18 @@
author, 'faucet', '',
'Miscellaneous'),
]

# -- Magic to run sphinx-apidoc automatically -----------------------------

# See https://github.com/rtfd/readthedocs.org/issues/1139
# on which this is based.

def run_apidoc(_):
"""Call sphinx-apidoc on faucet module"""
from sphinx.apidoc import main as apidoc_main
cur_dir = os.path.abspath(os.path.dirname(__file__))
apidoc_main([None, '-e', '-o', 'source/apidoc', '../faucet'])

def setup(app):
"""Over-ride Sphinx setup to trigger sphinx-apidoc."""
app.connect('builder-inited', run_apidoc)

0 comments on commit 5a5522e

Please sign in to comment.