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

Skip to content

Issue520 #541

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
Oct 19, 2011
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