-
Notifications
You must be signed in to change notification settings - Fork 132
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
Use the last image in a notebook as the default thumbnail #707
Conversation
dd19350
to
5ae7107
Compare
Thanks for this PR! This fits very well to the other gallery change: #706 I think if we do this we can drop the backwards-compatibility option.
Yeah, that would be unexpected. Which got me thinking: what happens when a thumbnail is both specified in a notebook and in
I don't think an additional option is necessary for this. I think if the priority is obvious (i.e. specified vs. implied), the obvious thing should happen, i.e. the user-specified image should be shown. Does that make sense? |
Agreed, that's a good way to handle it. |
f8b7d3a
to
bd53a34
Compare
Okay, I finally found where in the code the priority is actually handled! The previous behaviour was to prefer thumbnails specified in the notebook to those in the config (and this was denoted with a comment). This is probably still reasonable (e.g. if there was a fairly wide pattern). I've slotted the implicit thumbnail in below these options, as a fallback before resorting to the default. |
Thanks for the update! Do you think the I think it would be better to always take the last image as a fallback (unless there is no image at all, in which case the "no thumbnail" image would be used). It would be great to have a new example notebook that shows the new behavior. |
No problem, I can change it to work this way. I guess I didn't want to break anything existing by changing the default thumbnail to an image out of the notebook, but since the default thumbnail has changed to be pretty glaring it's fine now! It's also possible to just wildcard back to a default anyway.
Given that there won't be a specific configuration knob needed, I'm happy to make these changes now. |
The previous resolution order was to use a thumbnail specified in a notebook, then the one in the conf.py, if present. If a default implicit thumbnail is used, it should be lower priority than these two options.
afad86b
to
b99f1a4
Compare
Whoops, my example didn't quite work as intended! |
b99f1a4
to
c1317b4
Compare
Thanks for the update! However, there seems to be a bug somewhere, because the Also, the image in the
That's an interesting situation ... would you expect this to work? |
@@ -73,6 +73,7 @@ | |||
"* [Using a Cell Tag to Select a Thumbnail](cell-tag.ipynb)\n", | |||
"* [Using Cell Metadata to Select a Thumbnail](cell-metadata.ipynb)\n", | |||
"* [Choosing from Multiple Outputs](multiple-outputs.ipynb)\n", | |||
"* [Default Thumbnails](default-thumbnail.ipynb)\n", |
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.
Shouldn't be the default behavior the first in this list?
@angus-g Did you see my previous comment? Do you know what's going wrong in the It would be great if we could fix this and then merge this PR. If you don't have time, no problem, but please let me know so I can have a stab at fixing this. |
I don't want to be too impatient, but I took the liberty of using your commits and appending my own changes here: #717. I think this should fix most of my comments above. However, the image from |
I have merged #717, thanks for initiating this! I will make a new release soon. This way, the breaking changes are published and people can start using it. |
The
nbsphinx_thumbnail_default
configuration key controls whether the default thumbnail for a notebook is the default icon, if it is'none'
(the default). If it is'last'
and a notebook has any valid image outputs, the last of these will be used for the thumbnail.This is to get back to the default behaviour offered by sphinx_nbexamples. I'm not sure if it's possible to showcase this in the documentation, since it requires changing a config switch, rather than being per-notebook.
There is still a little snag here: because this setting provides a value for
nbsphinx_thumbnail
for all notebooks with an image, the custom thumbnails in thenbsphinx_thumbnails
config mapping are overwritten. I could also add another configuration key to determine whether the notebook or the config file is the authoritative source for the thumbnail, e.g.Example diff
Although this feels a little gross, I don't quite understand the ordering of
env
vs.config
. I guess otherwise this would go in at theenv_merge_info
stage...?