summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchebee7i <chebee7i@gmail.com>2015-06-14 18:36:40 -0500
committerchebee7i <chebee7i@gmail.com>2015-06-14 18:36:40 -0500
commitda06606f493b8aca0fc49f613cce1629450b74a2 (patch)
tree2a10c69568e360af54c19828827e3526835d3203
parent0fa9f97468e102be929dbac14aa6ab33e738779b (diff)
downloadnetworkx-docdraft.tar.gz
Get directories correct.docdraft
-rw-r--r--doc/source/conf.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py
index d2f2ffb9..e265348d 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -13,6 +13,25 @@
from __future__ import print_function
import sys, os, re
+import contextlib
+
+@contextlib.contextmanager
+def cd(newpath):
+ """
+ Change the current working directory to `newpath`, temporarily.
+
+ If the old current working directory no longer exists, do not return back.
+ """
+ oldpath = os.getcwd()
+ os.chdir(newpath)
+ try:
+ yield
+ finally:
+ try:
+ os.chdir(oldpath)
+ except OSError:
+ # If oldpath no longer exists, stay where we are.
+ pass
# Check Sphinx version
import sphinx
@@ -31,8 +50,12 @@ if on_rtd:
# Build is not via Makefile (yet).
# So we manually build the examples and gallery.
import subprocess
- subprocess.call([sys.executable, '../make_gallery.py'])
- subprocess.call([sys.executable, '../make_examples.py', '../examples', 'source'])
+ with cd('..'):
+ # The Makefile is run from networkx/doc, so we need to move there
+ # from networkx/doc/source (which holds conf.py).
+ py = sys.executable
+ subprocess.call([py, 'make_gallery.py'])
+ subprocess.call([py, 'make_examples.py', '../examples', 'source'])
# If your extensions are in another directory, add it here.
# These locations are relative to conf.py