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

Have a way to use Pluto default show for types which define a custom show method #2997

Open
disberd opened this issue Aug 13, 2024 · 3 comments

Comments

@disberd
Copy link
Contributor

disberd commented Aug 13, 2024

Currently, if I create a type MyType and define a override Base.show(io::IO, x::MyType) or Base.show(io::IO, ::MIME"text/plain", x::MyType), then I lose the default show method in Pluto, and there is not method to get it back.

It would be good to be able to decide I want my type to have a custom show in the REPL but do not impact the Pluto default show method.

I remember somebody raised this issue question before in either zulip/discourse but can't find it anymore.

Discussed this today at the dev call and @fonsp also agrees that we should have this capability

@disberd disberd changed the title Have a way to use Pluto default show for custom types which define a custom show method Have a way to use Pluto default show for types which define a custom show method Aug 13, 2024
@cstjean
Copy link

cstjean commented Aug 16, 2024

Having a way to "display this object as a Pluto object tree of ..." would also be very nice!

@MasonProtter
Copy link

Here's the Zulip thread with the request: https://julialang.zulipchat.com/#narrow/channel/243342-pluto.2Ejl/topic/show.20method

@MasonProtter
Copy link

MasonProtter commented Nov 1, 2024

Here's two potential ways to handle this:

  1. Give users a function they can call, so that e.g. they can write
Base.show(io::IO, ::MIME"text/html", x::MyType) = PlutoRunner.pluto_show(io, x)
  1. Define some trait they can overwrite that communicates to Pluto that it should use Pluto's tree-view instead of the regular show method
PlutoRunner.use_treeview(::MyType) = true

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

No branches or pull requests

3 participants