Config capture_repr on file-by-file basis #891
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make
gallery_conf['capture_repr']
overridable by# sphinx_gallery_capture_repr
file config comment.Use case: Sometimes, especially in examples with many short code sections, it is undesirable to have all the output boxes while you can't globally set
capture_repr
to()
as there are some examples in the gallery where the output is needed. Making all these short code sections end withplt.show()
or turning the last line into an assignment isn't ideal either as the former introduces a lot of extra lines of code and the latter may seem confusing, see matplotlib/matplotlib#21794 (putting a semicolon after the last expression doesn't work here as the code is first compiled into an AST and then the last expression is taken from the tree where the semicolon as code delimiter isn't present, see code).So with this PR it would be possible to globally set the normal capture representation and then define exception on a file-by-file basis.