Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to show/hide the source link in plot_directive #2645

Merged
merged 2 commits into from Dec 5, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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