As JupyterLite starts starts to finagle its way into Jupyter Book, such as via
jupyterlite-sphinx, in which a simple admonition can be used to embed an in-browser executable notebook or live JupyterLab environment:
or via thebe, to provide in-browser execution support for Jupyter Book executable cells (hopefully, soon… [issue, PR]), I thought I’d riff on the
jupyterlite-sphinx approach, which drops a jupyterlite disribution in to a Jupyter Book distribution, and see if I could open a Jupyter Book page rendered from a notebook in a RetroLite (JupyterLite notebook) editor. And it seems that a crude proof-of-concept at least wasn’t that hard, cribbing from an earlier example of how to launch a notebook in Deepnote via a PR in
executablebooks/sphinx-book-theme. (Things will be so much easier when this is pluggable…)
My attempt is currently at
ouseful-PR/sphinx-book-theme/tree/launch-in-jupyterlite and works by adding a new menu option to the launch menu (which can be used to open the source version of the page in Binderhub, or via a specified JupyterHub) that will open the notebook in a retrolite notebook using the retrolite environment that has been added as part of the book distribution:
What this means is you can “View Executable Source” on the Jupyter book page and tinker with it in a JupyterLite notebook editor. At least at first. Because any edits you make to the notebook are:
- saved to browser storage, so you can keep your changes;
- not rendered back to the Jupyter book page.
What this means is that the first time you launch the book page into the notebook editor, it does represent the source of the original page, but thereafter any edits mean the two versions differ. If you edit the notebook and then at a later date launch from the book page again, you will see the latest, edited version of the notebook as saved to browser storage.
What this POC throws up, then, is some user issues:
- it would be handy to know from the notebook page that the version being edited is different to the original version;
- it would be handy to revert the edited notebook back to the original version;
- it would be handy to know from the book page that an edited version of the notebook is available;
- it would be handy to be able to reflow the book page based on the edited notebook version.