diff --git a/doc/examples/README.rst b/doc/examples/README.txt
similarity index 100%
rename from doc/examples/README.rst
rename to doc/examples/README.txt
diff --git a/doc/examples/color_exposure/README.rst b/doc/examples/color_exposure/README.txt
similarity index 100%
rename from doc/examples/color_exposure/README.rst
rename to doc/examples/color_exposure/README.txt
diff --git a/doc/examples/edges/README.rst b/doc/examples/edges/README.txt
similarity index 100%
rename from doc/examples/edges/README.rst
rename to doc/examples/edges/README.txt
diff --git a/doc/examples/features_detection/README.rst b/doc/examples/features_detection/README.txt
similarity index 100%
rename from doc/examples/features_detection/README.rst
rename to doc/examples/features_detection/README.txt
diff --git a/doc/examples/filters/README.rst b/doc/examples/filters/README.txt
similarity index 100%
rename from doc/examples/filters/README.rst
rename to doc/examples/filters/README.txt
diff --git a/doc/examples/numpy_operations/README.rst b/doc/examples/numpy_operations/README.txt
similarity index 100%
rename from doc/examples/numpy_operations/README.rst
rename to doc/examples/numpy_operations/README.txt
diff --git a/doc/examples/segmentation/README.rst b/doc/examples/segmentation/README.txt
similarity index 100%
rename from doc/examples/segmentation/README.rst
rename to doc/examples/segmentation/README.txt
diff --git a/doc/examples/transform/README.rst b/doc/examples/transform/README.txt
similarity index 100%
rename from doc/examples/transform/README.rst
rename to doc/examples/transform/README.txt
diff --git a/doc/examples/xx_applications/README.rst b/doc/examples/xx_applications/README.txt
similarity index 100%
rename from doc/examples/xx_applications/README.rst
rename to doc/examples/xx_applications/README.txt
diff --git a/doc/ext/sphinx_gallery/docs_resolv.py b/doc/ext/sphinx_gallery/docs_resolv.py
index 0675a131..5e977111 100644
--- a/doc/ext/sphinx_gallery/docs_resolv.py
+++ b/doc/ext/sphinx_gallery/docs_resolv.py
@@ -58,7 +58,11 @@ def get_data(url, gallery_dir):
if sys.version_info[0] == 2 and isinstance(url, unicode):
url = url.encode('utf-8')
- cached_file = os.path.join(gallery_dir, 'searchindex')
+ cwd = os.getcwd()
+ if 'source' in cwd:
+ cached_file = os.path.join(gallery_dir, 'searchindex')
+ else:
+ cached_file = os.path.join('source', gallery_dir, 'searchindex')
search_index = shelve.open(cached_file)
if url in search_index:
data = search_index[url]
@@ -318,7 +322,6 @@ class SphinxDocLinkResolver(object):
def _embed_code_links(app, gallery_conf, gallery_dir):
# Add resolvers for the packages for which we want to show links
doc_resolvers = {}
-
for this_module, url in gallery_conf['reference_url'].items():
try:
if url is None:
@@ -341,9 +344,10 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
"Error:\n".format(this_module))
print(e.args)
+ working_dir = os.getcwd()
+ os.chdir(app.builder.srcdir)
html_gallery_dir = os.path.abspath(os.path.join(app.builder.outdir,
gallery_dir))
-
# patterns for replacement
link_pattern = '%s'
orig_pattern = '%s'
@@ -356,7 +360,6 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
subpath = dirpath[len(html_gallery_dir) + 1:]
pickle_fname = os.path.join(gallery_dir, subpath,
fname[:-5] + '_codeobj.pickle')
-
if os.path.exists(pickle_fname):
# we have a pickle file with the objects to embed links for
with open(pickle_fname, 'rb') as fid:
@@ -366,7 +369,6 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
# generate replacement strings with the links
for name, cobj in example_code_obj.items():
this_module = cobj['module'].split('.')[0]
-
if this_module not in doc_resolvers:
continue
@@ -403,6 +405,7 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
line = expr.sub(substitute_link, line)
fid.write(line.encode('utf-8'))
print('[done]')
+ os.chdir(working_dir)
def embed_code_links(app, exception):
diff --git a/doc/ext/sphinx_gallery/gen_gallery.py b/doc/ext/sphinx_gallery/gen_gallery.py
index 3da9a59a..e1698230 100644
--- a/doc/ext/sphinx_gallery/gen_gallery.py
+++ b/doc/ext/sphinx_gallery/gen_gallery.py
@@ -73,15 +73,16 @@ def generate_gallery_rst(app):
if not isinstance(gallery_dirs, list):
gallery_dirs = [gallery_dirs]
+ # cd to the appropriate directory regardless of sphinx configuration
+ working_dir = os.getcwd()
+ os.chdir(app.builder.srcdir)
+
mod_examples_dir = os.path.relpath(gallery_conf['mod_example_dir'],
app.builder.srcdir)
seen_backrefs = set()
computation_times = []
- # cd to the appropriate directory regardless of sphinx configuration
- working_dir = os.getcwd()
- os.chdir(app.builder.srcdir)
for examples_dir, gallery_dir in zip(examples_dirs, gallery_dirs):
examples_dir = os.path.relpath(examples_dir,
app.builder.srcdir)
@@ -100,7 +101,6 @@ def generate_gallery_rst(app):
seen_backrefs)
computation_times += this_computation_times
-
fhindex.write(this_fhindex)
for directory in sorted(os.listdir(examples_dir)):
if os.path.isdir(os.path.join(examples_dir, directory)):
@@ -113,7 +113,6 @@ def generate_gallery_rst(app):
computation_times += this_computation_times
fhindex.flush()
-
# Back to initial directory
os.chdir(working_dir)
diff --git a/doc/source/conf.py b/doc/source/conf.py
index f4a416f2..10d46de7 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -31,7 +31,7 @@ extensions = ['sphinx.ext.autodoc',
'sphinx.ext.imgmath',
'numpydoc',
'sphinx.ext.autosummary',
- 'plot2rst',
+ #'plot2rst',
'sphinx.ext.intersphinx',
'sphinx.ext.linkcode',
'sphinx_gallery.gen_gallery'
@@ -44,11 +44,17 @@ autosummary_generate = True
#------------------------------------------------------------------------
sphinx_gallery_conf = {
- # 'doc_module' : 'skimage',
+ 'doc_module' : 'skimage',
# path to your examples scripts
'examples_dirs' : '../examples',
# path where to save gallery generated examples
'gallery_dirs' : 'auto_examples',
+ 'mod_example_dir': 'api',
+ 'reference_url' : {
+ 'skimage': None,
+ 'matplotlib': 'http://matplotlib.org',
+ 'numpy': 'http://docs.scipy.org/doc/numpy-1.6.0',
+ 'scipy': 'http://docs.scipy.org/doc/scipy-0.11.0/reference',}
}
# Determine if the matplotlib has a recent enough version of the