-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add @register_renderable macro. #306
Conversation
Codecov Report
@@ Coverage Diff @@
## master #306 +/- ##
==========================================
+ Coverage 59% 59.24% +0.23%
==========================================
Files 17 17
Lines 622 633 +11
==========================================
+ Hits 367 375 +8
- Misses 255 258 +3
Continue to review full report at Codecov.
|
I confess that I think there is some redundancy here... Once we have As a counter-proposal, regardless of whether we choose function or macro (I personally prefer a macro not to have a macro register_renderable(T)
# define show methods for T
end and macro register_renderable(f, T)
# define show methods for T
# define WebIO.render(x::T) = f(x)
end To be used with the syntax: @register_renderable(MyType) do val
# define corresponding node
end And we could probably deprecate |
Yes, the plan (after I realized that I duplicated some register renderable stuff) is definitely to deprecate the function version. I also very much like that syntax (in addition to the bare |
@shashi @piever Are y'all happy with this? There's a bug(?) in Julia that makes the my preferred syntax slightly impossible (see JuliaLang/julia#32301). # This doesn't work.
WebIO.@register_renderable(MyType) do x
return node(:p, ...)
end It does work with the uglier syntax where we put the # This works
@WebIO.register_renderable(MyType) do x ... end It also works if you directly import the name. # This works
using WebIO: @register_renderable
@register_renderable(MyType) do x ... end) |
This addresses some of the issues that currently exist around extending WebIO.
It allows for a library author to write
This will automagically create the requisite
Base.show
methods forWEBIO_NODE_MIME
andtext/html
which is required to work correctly in Jupyter.Would help address JuliaPlots/PlotlyJS.jl#278.