Skip to content

Commit

Permalink
Automate doc building for readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
iMichka committed Oct 9, 2016
1 parent ea42088 commit e5f7941
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ help:
clean:
rm -rf $(BUILDDIR)/*

autogenerate:
sphinx-apidoc -o docs/apidocs pygccxml --separate --force --module-first --doc-project=API

html: autogenerate
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
Expand Down
23 changes: 23 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import os
import sphinx_rtd_theme
import subprocess

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -264,3 +265,25 @@
# Override autodoc defaults
autodoc_default_flags = [
"members", "undoc-members", "show-inheritance", "inherited-members"]

# Automate building apidoc when building with readthedocs
# https://github.com/rtfd/readthedocs.org/issues/1139
def run_apidoc(_):
modules = ['pygccxml']
for module in modules:
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(cur_dir, 'apidocs')
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'):
# Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(
os.path.join(sys.prefix, 'bin', 'sphinx-apidoc'))
subprocess.check_call(
[cmd_path, '-o', output_path, module,
'--separate', '--force', '--module-first', '--doc-project=API'])


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

0 comments on commit e5f7941

Please sign in to comment.