Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sphinx extension: support captions in inline plots.#15304

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

bcbnz
Copy link

PR Summary

This PR adds a:caption: option to the plot directive provided by the Sphinx extensionmatplotlib.sphinxext.plot_directive. Without this option, there is no way to specify a caption for a plot generated from inline content.

This is fully backwards-compatible. If a plot directive with a path to a source file has both a :caption: option and content provided, the content is used for the caption and the option is ignored.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@bcbnz
Copy link
Author

Force-pushed a new version which should fix the failing tests -- the docutils import should have been after the pytest.importorskip check that Sphinx was installed.

Incidentally, this means the CI doesn't have Sphinx installed and so these tests aren't actually run anyway...

This commit adds a :caption: option to the plot directive provided by theSphinx extension (matplotlib.sphinxext.plot_directive). Without thisoption, there is no way to specify a caption for a plot generated frominline content.This is fully backwards-compatible. If a plot directive with a path to asource file has both a :caption: option and content provided, thecontent is used for the caption and the option is ignored.
@bcbnzbcbnzforce-pushed thesphinxext-inline-caption branch from99e2e27 to4c9917eCompareSeptember 19, 2019 13:03
@bcbnz
Copy link
Author

And another force-push to fix a flake8 error due to the above move of the import.

Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

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

Thanks for the PR 🚀 - I think this looks like a good addition, and the code looks good to me (just one question). I'm not too experienced with testing these things, so will let someone else chime in on that part.

from docutils.nodes import caption, figure # noqa: E402

# Sphinx has some deprecation warnings we don't want to turn into errors.
with warnings.catch_warnings():
Copy link
Member

Choose a reason for hiding this comment

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

What are these warnings? I feel like long term we don't want to just ignore these.

Copy link
Author

@bcbnzbcbnzSep 27, 2019
edited
Loading

Choose a reason for hiding this comment

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

It's Jinja (imported by Sphinx) giving a DeprecationWarning: "Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop." This has been fixed in Jinja's master and should be included in the next release; seepallets/jinja#1028. The other warning (inbuild_test_doc()) is the same warning, also from Jinja and should also be fixed in the next release.

These warnings are only raised when importing Sphinx for test purposes (not in the actual library) so I don't think matplotlib needs to convert them to test failures.

@ulijhulijh mentioned this pull requestSep 8, 2020
7 tasks
@dopplershift
Copy link
Contributor

With#18426 merged, is there anything here left to merge?

@ulijh
Copy link
Contributor

The way of testing in this PR would be a plus...

@jklymak
Copy link
Member

Closing in favour of#18426, Sorry for the PR overlap, but I think it was an honest mistake...

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dstansbydstansbydstansby left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@bcbnz@dopplershift@ulijh@jklymak@dstansby@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp