From a47a60f8aebf24880ce441627ba8a720d48d810c Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 14 Oct 2009 08:51:25 +0200 Subject: [PATCH] Clean up output of plotting directive: - Do not generate PDFs. - Do not copy image to plots dir (Sphinx copies to _images already). --- doc/ext/plot_directive.py | 23 +++++++++++++++++------ doc/source/conf.py | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/doc/ext/plot_directive.py b/doc/ext/plot_directive.py index 24dc5598..05c5ce33 100644 --- a/doc/ext/plot_directive.py +++ b/doc/ext/plot_directive.py @@ -173,20 +173,28 @@ TEMPLATE = """ {%- for option in options %} {{ option }} {% endfor %} - + + (`Source code <{{source_link}}>`__) + + {# We do not need to link to all the different image + formats. The .png is included on the webpage, and a the + source snippet is given. + ( {%- if not source_code -%} `Source code <{{source_link}}>`__ - {%- for fmt in img.formats -%} + {%- for fmt in img.formats -%} , `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__ {%- endfor -%} {%- else -%} - {%- for fmt in img.formats -%} + {%- for fmt in img.formats -%} {%- if not loop.first -%}, {% endif -%} `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__ {%- endfor -%} {%- endif -%} ) + + #} {% endfor %} {{ only_latex }} @@ -332,9 +340,12 @@ def run(arguments, content, options, state_machine, state, lineno): if not os.path.exists(dest_dir): os.makedirs(dest_dir) - for img in images: - for fn in img.filenames(): - shutil.copyfile(fn, os.path.join(dest_dir, os.path.basename(fn))) +# Commented out so that images are not copied to the 'plots' +# directory. Sphinx copies to images to '_images' anyway, so no need. + +# for img in images: +# for fn in img.filenames(): +# shutil.copyfile(fn, os.path.join(dest_dir, os.path.basename(fn))) # copy script (if necessary) if source_file_name == rst_file: diff --git a/doc/source/conf.py b/doc/source/conf.py index f3375beb..69340d79 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -228,7 +228,7 @@ import matplotlib.pyplot as plt np.random.seed(0) """ plot_include_source = False -plot_formats = [('png', 100), 'pdf'] +plot_formats = [('png', 100)] import math phi = (math.sqrt(5) + 1)/2