Skip to content

Commit

Permalink
Merge pull request #3132 from nipy/doc/make-examples-2
Browse files Browse the repository at this point in the history
DOC: Revise generation of examples to work in RTD
  • Loading branch information
oesteban authored Jan 2, 2020
2 parents f4d0f9e + f4d418d commit 75a66b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 108 deletions.
6 changes: 0 additions & 6 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ help:
"items (ChangeLog)"
@echo " linkcheck check all external links for integrity"
@echo " doctest run all doctests embedded in the documentation"
@echo " sf_satra copy html files to sourceforge (satra only)"

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

examples2rst: clean
mkdir -p users/examples
../tools/make_examples.py -x ../../../examples/test_spm.py --no-exec
@echo "examples2rst finished."

latex: clean
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
@echo
Expand Down
10 changes: 9 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
from packaging.version import Version
import nipype

doc_path = os.path.abspath(os.path.dirname(__file__))
os.makedirs('users/examples', exist_ok=True)
os.system('python ../tools/make_examples.py -x ../../../examples/test_spm.py --no-exec')

os.chdir(os.path.join(doc_path, 'users', 'examples'))
os.system("""python ../../../tools/ex2rst -x ../../../examples/test_spm.py \
--project Nipype --outdir . ../../../examples""")
os.system("""python ../../../tools/ex2rst --project Nipype --outdir . \
../../../examples/frontiers_paper""")
os.chdir(doc_path)


# 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
13 changes: 7 additions & 6 deletions tools/ex2rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ def exfile2rstfile(filename, opts):
"""
# doc filename
dfilename = os.path.basename(filename[:-3]) + '.rst'
dfilepath = os.path.join(opts.outdir, os.path.basename(dfilename))
print("Creating file %s." % os.path.abspath(dfilepath))

# open dest file
dfile = open(os.path.join(opts.outdir, os.path.basename(dfilename)), 'w')
dfile = open(dfilepath, 'w')

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


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

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

if not os.path.exists(opts.outdir):
os.mkdir(outdir)
os.makedirs(opts.outdir, exist_ok=True)

# finally process all examples
for t in toparse:
Expand Down
95 changes: 0 additions & 95 deletions tools/make_examples.py

This file was deleted.

0 comments on commit 75a66b9

Please sign in to comment.