Skip to content

DOC: Revise generation of examples to work in RTD #3132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.