jupyterlite-sphinx
jupyterlite-sphinx copied to clipboard
Investigate more immersive integration of interactive API examples, inspired by `sphinx-thebe`
Problem
The TryExamples directive currently reveals an iframe from a "Try it" button to showcase notebooks for a Pyodide kernel, which then displays the Notebook interface containing the example formatted in a cell with surrounding Markdown. While it is completely functional—of course—it is not "immersive" and does not fully integrate with the rest of the surrounding elements on the docs page.
Proposed Solution
Enable connecting to a Xeus/Pyodide kernel more seamlessly, in a way that is less intrusive on the page, by reworking the UI similar to this example from the sphinx-thebe documentation: https://sphinx-thebe.readthedocs.io/en/latest/use.html#an-example.
It can be used as a "MyST-NB" adapter of sorts as well, so that one does not need to open a new tab to run a notebook embedded as HTML separately – they can just connect to a kernel (which, by the way, is a single one for all cells on the page, see #2), and magically spring up the notebook cells into interactivity without leaving the page.
This would require a significant amount of work, around:
- enabling just one kernel per page (if notebooks are to be supported, otherwise no)
- modifying the JupyterLite UI upstream or disabling as many visual elements as possible, so that just a minimal code cell remains (and is editable)
- being able to "communicate" between WASM kernels and the output in the same way as Binder does
Additional context
- https://github.com/executablebooks/meta/issues/68
- as mentioned,
sphinx-thebeconnects to a kernel hosted via Binder instead of WASM kernels, and maybe it's possible to implement support for it there rather than here (I don't know at this time).
xref: https://github.com/jupyterlite/jupyterlite/issues/148 and #63
Of note, there is also thebe-lite, with some docs here: https://mystmd.org/thebe/quickstart-lite