Skip to content

Add :shows-source-link: option to Sphinx plot directive #24215

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

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

lpsinger
Copy link
Contributor

@lpsinger lpsinger commented Oct 18, 2022

The Sphinx plot directive (.. plot::) now supports a :show-source-link option to show or hide the link to the source for each plot. The default is set using the plot_html_show_source_link variable in conf.py (which itself defaults to True).

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@lpsinger lpsinger force-pushed the show-source-link-option branch 2 times, most recently from 9c5a5dc to 8fae504 Compare October 18, 2022 19:50
@MikhailRyazanov
Copy link
Contributor

MikhailRyazanov commented Oct 18, 2022

Just a remark that source links are currently broken for singlehtml and dirhtml builders (as well as for building multiple targets, for example, html after latex), see issues #13858 and #24005 and the proposed solution in PR #24205. Not that this PR makes the problem worse, but it modifies the broken file-copying code and depends on its behavior in the tests.

@lpsinger
Copy link
Contributor Author

Any update on this?

@story645 story645 added the Documentation: build building the docs label Nov 11, 2022
@story645 story645 added this to the v3.7.0 milestone Nov 11, 2022
@lpsinger lpsinger requested review from story645 and removed request for timhoffm November 11, 2022 15:31
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was held up by #24215 (comment). But now realized that we're not hooking deeper into that functionality for execution. We only rely on it in tests. - Therefore, the worst that can happen is that our tests become broken and we have to come up with a better test, but the functionality on the user side is not affect.

This is good to go, modulo my comment on the test.

@lpsinger lpsinger force-pushed the show-source-link-option branch 2 times, most recently from 0379f0d to a126736 Compare November 11, 2022 17:52
@lpsinger lpsinger requested review from timhoffm and removed request for story645 November 11, 2022 17:53
@lpsinger lpsinger force-pushed the show-source-link-option branch from a126736 to 3f011be Compare November 11, 2022 17:53
@timhoffm
Copy link
Member

Precommit sees trailing whitespace

@lpsinger
Copy link
Contributor Author

I pushed one more little change to fix this error from the CI pipeline:

trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing doc/users/next_whats_new/show_source_links_directive_option.rst

@lpsinger
Copy link
Contributor Author

Precommit sees trailing whitespace

That's fixed now. Should be ready to go.

@story645
Copy link
Member

@lpsinger do you want to squash/rebase or should I?

The Sphinx plot directive (`.. plot::`) now supports a
`:show-source-link` option to show or hide the link to the source
for each plot. The default is set using the
`plot_html_show_source_link` variable in `conf.py` (which itself
defaults to True).
@lpsinger
Copy link
Contributor Author

@lpsinger do you want to squash/rebase or should I?

Done.

@lpsinger lpsinger force-pushed the show-source-link-option branch from 2fea052 to d58fc21 Compare November 11, 2022 20:19
@timhoffm timhoffm merged commit 19d9340 into matplotlib:main Nov 11, 2022
@timhoffm
Copy link
Member

Thanks @lpsinger

@lpsinger
Copy link
Contributor Author

Thank you!

@lpsinger lpsinger deleted the show-source-link-option branch November 11, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: build building the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants