|
71 | 71 | inserted. This is usually useful with the ``:context:`` option.
|
72 | 72 |
|
73 | 73 | outname : str
|
74 |
| - If specified, the names of the generated plots will start with the value |
75 |
| - of `:outname:`. This is handy for preserving output results if code is |
76 |
| - reordered between runs. The value of `:outname:` must be unique across |
77 |
| - the generated documentation. |
| 74 | + If specified, the names of the generated plots will start with the |
| 75 | + value of `:outname:`. This is handy for preserving output results if |
| 76 | + code is reordered between runs. The value of `:outname:` must be |
| 77 | + unique across the generated documentation. |
78 | 78 |
|
79 | 79 | Additionally, this directive supports all of the options of the `image`
|
80 | 80 | directive, except for *target* (since plot will add its own target). These
|
|
142 | 142 | Files with outnames are copied to this directory and files in this
|
143 | 143 | directory are copied back from into the build directory prior to the
|
144 | 144 | build beginning.
|
| 145 | +
|
145 | 146 | """
|
146 | 147 |
|
147 | 148 | import contextlib
|
@@ -677,13 +678,14 @@ def run(arguments, content, options, state_machine, state, lineno):
|
677 | 678 | #Ensure that the outname is unique, otherwise copied images will
|
678 | 679 | #not be what user expects
|
679 | 680 | if outname and outname in _outname_list:
|
680 |
| - raise Exception("The outname '{0}' is not unique!".format(outname)) |
| 681 | + raise Exception("The outname '{0}' is not unique!".format(outname)) |
681 | 682 | else:
|
682 |
| - _outname_list.add(outname) |
| 683 | + _outname_list.add(outname) |
683 | 684 |
|
684 | 685 | if config.plot_preserve_dir:
|
685 |
| - #Ensure `preserve_dir` ends with a slash, otherwise `copy2` will misbehave |
686 |
| - config.plot_preserve_dir = os.path.join(config.plot_preserve_dir, '') |
| 686 | + # Ensure `preserve_dir` ends with a slash, otherwise `copy2` |
| 687 | + # will misbehave |
| 688 | + config.plot_preserve_dir = os.path.join(config.plot_preserve_dir, '') |
687 | 689 |
|
688 | 690 | if len(arguments):
|
689 | 691 | if not config.plot_basedir:
|
@@ -723,7 +725,7 @@ def run(arguments, content, options, state_machine, state, lineno):
|
723 | 725 | #outname, if present, overrides output_base, but preserve
|
724 | 726 | #numbering of multi-figure code snippets
|
725 | 727 | if outname:
|
726 |
| - output_base = re.sub('^[^-]*', outname, output_base) |
| 728 | + output_base = re.sub('^[^-]*', outname, output_base) |
727 | 729 |
|
728 | 730 | # ensure that LaTeX includegraphics doesn't choke in foo.bar.pdf filenames
|
729 | 731 | output_base = output_base.replace('.', '-')
|
@@ -775,10 +777,12 @@ def run(arguments, content, options, state_machine, state, lineno):
|
775 | 777 | #this copies them into the build directory so that they will
|
776 | 778 | #not be remade
|
777 | 779 | if config.plot_preserve_dir and outname:
|
778 |
| - outfiles = glob.glob(os.path.join(config.plot_preserve_dir, outname) + '*') |
779 |
| - for of in outfiles: |
780 |
| - _log.info("Copying preserved copy of '{0}' into '{1}'".format(of, build_dir)) |
781 |
| - shutil.copy2(of, build_dir) |
| 780 | + outfiles = glob.glob( |
| 781 | + os.path.join(config.plot_preserve_dir, outname) + '*') |
| 782 | + for of in outfiles: |
| 783 | + _log.info("Copying preserved copy of '{0}' into '{1}'".format( |
| 784 | + of, build_dir)) |
| 785 | + shutil.copy2(of, build_dir) |
782 | 786 |
|
783 | 787 | # make figures
|
784 | 788 | try:
|
|
0 commit comments