Skip to content

Commit 780ea18

Browse files
committed
Save script if necessary
1 parent a8977fd commit 780ea18

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,11 @@ def run(arguments, content, options, state_machine, state, lineno):
866866
shutil.copyfile(fn, destimg)
867867

868868
# copy script (if necessary)
869-
Path(dest_dir, output_base + source_ext).write_text(
870-
doctest.script_from_examples(code)
871-
if source_file_name == rst_file and is_doctest
872-
else code,
873-
encoding='utf-8')
869+
if config.plot_html_show_source_link:
870+
Path(dest_dir, output_base + source_ext).write_text(
871+
doctest.script_from_examples(code)
872+
if source_file_name == rst_file and is_doctest
873+
else code,
874+
encoding='utf-8')
874875

875876
return errors

0 commit comments

Comments
 (0)