[tor-commits] [stem/master] Running apidoc when being built by read-the-docs

atagar at torproject.org atagar at torproject.org
Tue Sep 25 16:54:46 UTC 2012


commit 705b61674e8cec9e5608a32c6a50a708fee8c5f7
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Sep 25 09:51:26 2012 -0700

    Running apidoc when being built by read-the-docs
    
    The read-the-docs service runs sphinx-build, bypassing our custom Makefile. The
    only gotcha with this is that it means we don't call apidoc, causing our
    autogenerated documentation (which is... well, just about everything) to not
    exist.
    
    Making the apidoc in the conf.py file, using the READTHEDOCS environment
    variable to deterine if we're on that platform or not.
    
    Tested by first running a regular sphinx build to repro the apidoc not being
    called...
    
    sphinx-build -b html -d _build/doctrees . _build/html
    
    ... then did it again after setting READTHEDOCS to confirm that the autodocs
    now existed.
---
 docs/conf.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index ada61ec..0bdd83c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,6 +13,15 @@
 
 import sys, os
 
+# Our make file calls sphinx-apidoc, but read-the-docs uses our config instead
+# (so it skips that step). Calling apidoc here instead if we're being built
+# there.
+
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if on_rtd:
+  os.system("sphinx-apidoc -f -o . ../stem")
+
 # 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
 # documentation root, use os.path.abspath to make it absolute, like shown here.



More information about the tor-commits mailing list