jupyter / jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
https://jupyter-sphinx.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
187 stars 65 forks source link

Generate and include screenshot images of the output cell #212

Closed Davide-sd closed 1 year ago

Davide-sd commented 1 year ago

I'm working on a plotting module in which each plotting function might contain in its docstring one or more examples of interactive plots with widgets. Ideally, I would like to execute and render the output of those examples. However, I've noticed a couple of issues:

  1. 3D plots tends to be much "heavier" than 2D plots, which will slow down significantly the loading of the page.
  2. When using different plotting libraries (plotly, bokeh, matplotlib, ...) on the same page, there might be situations in which the data is there, but javascript fails to load some module, hence none of the jupyter outpull cells gets rendered.

One way to solve both issues might be to generate a screenshot image of the output cell, and include that instead of the actual content of the output cell.

Do you think it would be possible to implement such option?

akhmerov commented 1 year ago

I think this is highly library-specific, and nearly impossible to accommodate within jupyter-sphinx. Converting a generic HTML object to a static image effectively requires using a browser rendering engine I think. For example, plotly uses a separate library kaleido to generate static outputs.

Davide-sd commented 1 year ago

You are totally right. I've manage to create an extension that satisfies my needs, sphinx_panel_screenshot. Thank you for pointing me in the right direction. I'm closing this issue.