Skip to content

Commit f4d418d

Browse files
committed
DOC: Revise generation of examples to work in RTD
Amends nipy#3131.
1 parent f4d0f9e commit f4d418d

File tree

4 files changed

+16
-108
lines changed

4 files changed

+16
-108
lines changed

doc/Makefile

-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ help:
2222
"items (ChangeLog)"
2323
@echo " linkcheck check all external links for integrity"
2424
@echo " doctest run all doctests embedded in the documentation"
25-
@echo " sf_satra copy html files to sourceforge (satra only)"
2625

2726
clean:
2827
-rm -rf _build/* *~ api/generated interfaces/generated users/examples documentation.zip
@@ -35,11 +34,6 @@ htmlonly:
3534
html: clean htmlonly
3635
@echo "Build HTML and API finished."
3736

38-
examples2rst: clean
39-
mkdir -p users/examples
40-
../tools/make_examples.py -x ../../../examples/test_spm.py --no-exec
41-
@echo "examples2rst finished."
42-
4337
latex: clean
4438
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
4539
@echo

doc/conf.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@
1616
from packaging.version import Version
1717
import nipype
1818

19+
doc_path = os.path.abspath(os.path.dirname(__file__))
1920
os.makedirs('users/examples', exist_ok=True)
20-
os.system('python ../tools/make_examples.py -x ../../../examples/test_spm.py --no-exec')
21+
22+
os.chdir(os.path.join(doc_path, 'users', 'examples'))
23+
os.system("""python ../../../tools/ex2rst -x ../../../examples/test_spm.py \
24+
--project Nipype --outdir . ../../../examples""")
25+
os.system("""python ../../../tools/ex2rst --project Nipype --outdir . \
26+
../../../examples/frontiers_paper""")
27+
os.chdir(doc_path)
28+
2129

2230
# If extensions (or modules to document with autodoc) are in another directory,
2331
# add these directories to sys.path here. If the directory is relative to the

tools/ex2rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ def exfile2rstfile(filename, opts):
158158
"""
159159
# doc filename
160160
dfilename = os.path.basename(filename[:-3]) + '.rst'
161+
dfilepath = os.path.join(opts.outdir, os.path.basename(dfilename))
162+
print("Creating file %s." % os.path.abspath(dfilepath))
161163

162164
# open dest file
163-
dfile = open(os.path.join(opts.outdir, os.path.basename(dfilename)), 'w')
165+
dfile = open(dfilepath, 'w')
164166

165167
# place header
166168
dfile.write('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n')
@@ -196,8 +198,8 @@ def exfile2rstfile(filename, opts):
196198

197199

198200
def main():
199-
parser = OptionParser( \
200-
usage="%prog [options] <filename|directory> [...]", \
201+
parser = OptionParser(
202+
usage="%prog [options] <filename|directory> [...]",
201203
version="%prog 0.1", description="""\
202204
%prog converts Python scripts into restructered text (ReST) format suitable for
203205
integration into the Sphinx documentation framework. Its key feature is that it
@@ -217,7 +219,7 @@ the respective indentation is removed in the ReST output.
217219
218220
The parser algorithm automatically excludes file headers and starts with the
219221
first (module-level) docstring instead.
220-
""" ) #'
222+
""")
221223

222224
# define options
223225
parser.add_option(
@@ -293,8 +295,7 @@ Name of the project that contains the examples. This name is used in the
293295
if len(toparse) != len(toparse_list):
294296
print('Ignoring duplicate parse targets.')
295297

296-
if not os.path.exists(opts.outdir):
297-
os.mkdir(outdir)
298+
os.makedirs(opts.outdir, exist_ok=True)
298299

299300
# finally process all examples
300301
for t in toparse:

tools/make_examples.py

-95
This file was deleted.

0 commit comments

Comments
 (0)