Skip to content
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

proposal for rendering images when last value from @example blocks #2533

Open
tpapp opened this issue Jun 22, 2024 · 5 comments
Open

proposal for rendering images when last value from @example blocks #2533

tpapp opened this issue Jun 22, 2024 · 5 comments

Comments

@tpapp
Copy link
Contributor

tpapp commented Jun 22, 2024

This is a feature request. I am wondering if it would be possible to just render plots when they are the last value in @example blocks (& similar).

Currently, the manual suggests something not unlike

```@example
make_my_plot(....)
save_my_plot("filename.svg", ans); nothing # hide
```

![](filename.svg)

What I am proposing is the following:

  1. When the block is run, the last value is inspected with Base.Multimedia.showable for a list of predefined MIME types (eg svg, png).

  2. If one of them returns true, the corresponding value from show is captured into a file, which is assigned a unique name (eg in a subdirectory dedicated for this purpose, a hash or an integer counter).

  3. The image is included in the output.

@fredrikekre
Copy link
Member

I thought this is how it works already?

@tpapp
Copy link
Contributor Author

tpapp commented Jun 22, 2024

@fredrikekre: are you sure about this? Can you link a repo where that is used?

@mortenpi
Copy link
Member

We also have the SVG example in the Documenter showcase: https://documenter.juliadocs.org/stable/showcase/#Running-interactive-code

Currently, the manual suggests something not unlike

I think we should update the docs here. I feel that show methods are preferred (although the explicit inclusion can also be useful when the show method can't be used for one reason or another).

@tpapp
Copy link
Contributor Author

tpapp commented Jun 23, 2024

Thanks, I now see that it is working fine, it just needs to be updated in the docs.

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

No branches or pull requests

3 participants