Skip to content

Commit

Permalink
Merge pull request #2645 from loicseguin/show-source-link
Browse files Browse the repository at this point in the history
Add option to show/hide the source link in plot_directive
  • Loading branch information
pelson committed Dec 5, 2013
2 parents 4af0b5d + 8dbb009 commit c0e5c99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/matplotlib/sphinxext/plot_directive.py
Expand Up @@ -82,6 +82,9 @@
plot_include_source
Default value for the include-source option
plot_html_show_source_link
Whether to show a link to the source in HTML.
plot_pre_code
Code that should be executed before each plot.
Expand Down Expand Up @@ -304,6 +307,7 @@ def setup(app):
app.add_directive('plot', plot_directive, True, (0, 2, False), **options)
app.add_config_value('plot_pre_code', None, True)
app.add_config_value('plot_include_source', False, True)
app.add_config_value('plot_html_show_source_link', True, True)
app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True)
app.add_config_value('plot_basedir', None, True)
app.add_config_value('plot_html_show_formats', True, True)
Expand Down Expand Up @@ -388,9 +392,9 @@ def remove_coding(text):
{{ only_html }}
{% if source_link or (html_show_formats and not multi_image) %}
{% if (source_link and html_show_source_link) or (html_show_formats and not multi_image) %}
(
{%- if source_link -%}
{%- if source_link and html_show_source_link -%}
`Source code <{{ source_link }}>`__
{%- endif -%}
{%- if html_show_formats and not multi_image -%}
Expand Down Expand Up @@ -805,6 +809,7 @@ def run(arguments, content, options, state_machine, state, lineno):
dest_dir=dest_dir_link,
build_dir=build_dir_link,
source_link=src_link,
html_show_source_link=config.plot_html_show_source_link,
multi_image=len(images) > 1,
only_html=only_html,
only_latex=only_latex,
Expand Down

0 comments on commit c0e5c99

Please sign in to comment.