Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00860f8

Browse filesBrowse files
committed
plot_preserve_dir > plot_cache_dir
1 parent b2c2382 commit 00860f8
Copy full SHA for 00860f8

File tree

2 files changed

+15
-15
lines changed
Filter options

2 files changed

+15
-15
lines changed

‎doc/users/next_whats_new/2018_12_03_sphinx_plot_preserve.rst

Copy file name to clipboardExpand all lines: doc/users/next_whats_new/2018_12_03_sphinx_plot_preserve.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Plot Directive `outname` and `plot_preserve_dir`
2-
----------------------------------------------------
1+
Plot Directive `outname` and `plot_cache_dir`
2+
---------------------------------------------
33

44
The Sphinx plot directive can be used to automagically generate figures for
55
documentation like so:
@@ -49,13 +49,13 @@ e.g. :file:`docfile3-4-01.png` or something equally mysterious. With
4949
easy to understand which output image is which and, more importantly, uniquely
5050
keys output images to code snippets.
5151

52-
The ``plot_preserve_dir`` configuration value
53-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
The ``plot_cache_dir`` configuration value
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5454

55-
Setting the ``plot_preserve_dir`` configuration value to the name of a
55+
Setting the ``plot_cache_dir`` configuration value to the name of a
5656
directory will cause all images with ``:outname:`` set to be copied to this
5757
directory upon generation.
5858

59-
If an image is already in ``plot_preserve_dir`` when documentation is being
59+
If an image is already in ``plot_cache_dir`` when documentation is being
6060
generated, this image is copied to the build directory thereby pre-empting
6161
generation and reducing computation time in low-resource environments.

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
plot_template
146146
Provide a customized template for preparing restructured text.
147147
148-
plot_preserve_dir
148+
plot_cache_dir
149149
Files with outnames are copied to this directory and files in this
150150
directory are copied back into the build directory prior to the build
151151
beginning.
@@ -300,7 +300,7 @@ def setup(app):
300300
app.add_config_value('plot_apply_rcparams', False, True)
301301
app.add_config_value('plot_working_directory', None, True)
302302
app.add_config_value('plot_template', None, True)
303-
app.add_config_value('plot_preserve_dir', '', True)
303+
app.add_config_value('plot_cache_dir', '', True)
304304
app.connect('doctree-read', mark_plot_labels)
305305
app.add_css_file('plot_directive.css')
306306
app.connect('build-finished', _copy_css_file)
@@ -635,12 +635,12 @@ def render_figures(code, code_path, output_dir, output_base, context,
635635
for fmt, dpi in formats:
636636
try:
637637
figman.canvas.figure.savefig(img.filename(fmt), dpi=dpi)
638-
if config.plot_preserve_dir and outname is not None:
638+
if config.plot_cache_dir and outname is not None:
639639
_log.info(
640640
"Preserving '{0}' into '{1}'".format(
641-
img.filename(fmt), config.plot_preserve_dir))
641+
img.filename(fmt), config.plot_cache_dir))
642642
shutil.copy2(img.filename(fmt),
643-
config.plot_preserve_dir)
643+
config.plot_cache_dir)
644644
except Exception as err:
645645
raise PlotError(traceback.format_exc()) from err
646646
img.formats.append(fmt)
@@ -686,10 +686,10 @@ def run(arguments, content, options, state_machine, state, lineno):
686686
else:
687687
_outname_list.add(outname)
688688

689-
if config.plot_preserve_dir:
689+
if config.plot_cache_dir:
690690
# Ensure `preserve_dir` ends with a slash, otherwise `copy2`
691691
# will misbehave
692-
config.plot_preserve_dir = os.path.join(config.plot_preserve_dir, '')
692+
config.plot_cache_dir = os.path.join(config.plot_cache_dir, '')
693693

694694
if len(arguments):
695695
if not config.plot_basedir:
@@ -803,9 +803,9 @@ def run(arguments, content, options, state_machine, state, lineno):
803803

804804
# If we previously preserved copies of the generated figures this copies
805805
# them into the build directory so that they will not be remade.
806-
if config.plot_preserve_dir and outname:
806+
if config.plot_cache_dir and outname:
807807
outfiles = glob.glob(
808-
os.path.join(config.plot_preserve_dir, outname) + '*')
808+
os.path.join(config.plot_cache_dir, outname) + '*')
809809
for of in outfiles:
810810
_log.info("Copying preserved copy of '{0}' into '{1}'".format(
811811
of, build_dir))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.