r-lib / pkgdown

Generate static html documentation for an R package
https://pkgdown.r-lib.org/
Other
722 stars 336 forks source link

Improve output rendering in examples #1256

Closed jayhesselberth closed 3 years ago

jayhesselberth commented 4 years ago

Need to increase flexibility of output rendering so that documentation examples with htmlwidget output (#742) or gganimate objects (#935 and #941 ) render correctly.

Need to consider whether this should done with knitr (as in #941 and #742) or with repr (#959).

Would also be nice to be able to specify knitr options in examples.

flying-sheep commented 4 years ago

The rationale for writing repr instead of using knitr: https://github.com/r-lib/pkgdown/issues/959#issuecomment-453553830

I like having modular general-purpose packages that are agnostic towards from where they’re used. knitr’s knit_print is all but that.

jayhesselberth commented 4 years ago

@flying-sheep can you confirm how/if repr supports gganimate objects? Sorry if I'm rehashing, can't remember if this came up. I assume you would add a generic in repr?

flying-sheep commented 4 years ago

Sorry, idk about gganimate. It generally supports htmlwidgets if that matters. To support anything, you implement repr_<format>.<class>, I assume in this case a repr_html.gif_image function or so.

krlmlr commented 4 years ago

I hacked my way around it for dm in https://github.com/krlmlr/dm/commit/211f2d19fc5217b96d9c209fa6854203641ddc4c:

Looking forward to a "proper" solution still.

Bisaloo commented 4 years ago

My use case is adding interactive webGL plots using knitr::hook_webgl().

I don't know if this can be done with repr as well.

dmurdoch commented 3 years ago

@Bisaloo : I've made a number of improvements in the way rgl works with knitr recently. My next goal is to get it to work well in pkgdown too.

hadley commented 3 years ago

I think this is now mostly handled by @dmurdoch's work (or at least will be when all the pieces come together, hopefully in the very near future).