Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
24 changes: 12 additions & 12 deletions doc/sphinxext/gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ def generate_example_rst(app):

fhsubdirIndex.write(' %s <%s>\n'%(os.path.basename(basename),rstfile))

do_plot = (subdir in ('api',
'pylab_examples',
'units',
'mplot3d',
'axes_grid',
) and
not noplot_regex.search(contents))
if not do_plot:
fhstatic = file(outputfile, 'w')
fhstatic.write(contents)
fhstatic.close()

if not out_of_date(fullpath, outrstfile):
continue

Expand All @@ -121,25 +133,13 @@ def generate_example_rst(app):
title = '%s example code: %s'%(subdir, fname)
#title = '<img src=%s> %s example code: %s'%(thumbfile, subdir, fname)


fh.write(title + '\n')
fh.write('='*len(title) + '\n\n')

do_plot = (subdir in ('api',
'pylab_examples',
'units',
'mplot3d',
'axes_grid',
) and
not noplot_regex.search(contents))

if do_plot:
fh.write("\n\n.. plot:: %s\n\n::\n\n" % fullpath)
else:
fh.write("[`source code <%s>`_]\n\n::\n\n" % fname)
fhstatic = file(outputfile, 'w')
fhstatic.write(contents)
fhstatic.close()

# indent the contents
contents = '\n'.join([' %s'%row.rstrip() for row in contents.split('\n')])
Expand Down
11 changes: 7 additions & 4 deletions lib/matplotlib/sphinxext/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,13 @@ def run(arguments, content, options, state_machine, state, lineno):
shutil.copyfile(fn, destimg)

# copy script (if necessary)
target_name = os.path.join(dest_dir, output_base + source_ext)
f = open(target_name, 'w')
if source_file_name == rst_file:
target_name = os.path.join(dest_dir, output_base + source_ext)
f = open(target_name, 'w')
f.write(unescape_doctest(code))
f.close()
code_escaped = unescape_doctest(code)
else:
code_escaped = code
f.write(code_escaped)
f.close()

return errors