-
Notifications
You must be signed in to change notification settings - Fork 207
Optional flag to defer figure scraping to the next code block #801
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
Conversation
I have definitely wanted something like this before. It looks like there is a failure on Sphinx dev but this might be Sphinx's fault... It would be good to add a test for this somewhere, though. Maybe in |
8d90d43
to
ac3adfb
Compare
Okay, documentation and tests added, and all checks are green aside from Sphinx dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1 for merge
@lucyleeow do you want to look and merge if you're happy?
Will take a look this weekend, thanks @larsoner |
Did we want to do something about the sphinx dev fail? Is it possible to mark xfail if sphinx is a certain version? |
Someone should probably look in a separate PR to see why it fails. For example maybe they added another class to the CSS, so we just need to update. Or they removed one and it's not backward compatible and we need to open an issue with them. It sounds like you might be volunteering to look @lucyleeow ? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, very useful, thanks @ayshih ! One small nitpick about the docs, but I'm open to it staying there.
doc/advanced.rst
Outdated
plt.show() | ||
|
||
If config comments are requested to be removed from rendered output (see | ||
:ref:`removing_config_comments`), these flag comments will be removed as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer this to be in the configuration.rst
file (maybe above the 'image_scrapers' section) - it seems to fit with the things there and I think it would be a 'common' usage of Sphinx (rather than 'advanced' usage)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I moved the documentation (to below "Image scrapers", since that is the first mention of scraping)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
It's on my todo! |
Closes #363
This PR adds an optional flag for a code block to defer figure scraping to the next code block. If the code-block executor sees the comment
# sphinx_gallery_defer_figures
, it will not runsave_figures()
to scrape figures, and any figures are left open for the next code block. Thus, it becomes possible to interleave text blocks between multiple code blocks of plotting commands, with no figures being shown until after the desired code block.The flag gets stripped out along with the usual config comments (e.g.,
# sphinx_gallery_thumbnail_number = N
).Here's a rendered example:

where the first code block is:
This needs documentation and tests, of course, but I wanted feedback first.