Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Config capture_repr on file-by-file basis #891

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
Dec 10, 2021

Conversation

StefRe
Copy link
Contributor

@StefRe StefRe commented Dec 9, 2021

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 with plt.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.

Copy link
Contributor

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

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

LGTM! Small nit

Make gallery_conf['capture_repr'] overridable by
sphinx_gallery_capture_repr file config comment.
@lucyleeow
Copy link
Contributor

Thanks! I'll see if @larsoner wants to take a look, otherwise I'll merge next week!

@larsoner larsoner merged commit fabc70a into sphinx-gallery:master Dec 10, 2021
@larsoner
Copy link
Contributor

Thanks @StefRe !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants