From 8b3345f2841f9669c3db658a4964a23887f5718a Mon Sep 17 00:00:00 2001 From: "Angel L. P." <59593766+angelphanth@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:27:17 +0200 Subject: [PATCH 1/5] adding `sphinx-thebe` as docs dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 595531f..1eaf185 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ docs = [ "sphinx-new-tab-link!=0.2.2", "jupytext", "sphinx-copybutton", + "sphinx-thebe" ] # local development options dev = ["black[jupyter]", "ruff", "pytest", "isort", "jupytext"] From 1db536c8f563f0df21e83cf77cbcc038cbec8a0e Mon Sep 17 00:00:00 2001 From: "Angel L. P." <59593766+angelphanth@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:32:08 +0200 Subject: [PATCH 2/5] configuration for binder and thebe --- docs/conf.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fbaa22f..67a9e8f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,6 +37,7 @@ "sphinx_new_tab_link", # each link opens in a new tab "myst_nb", # Markdown and Jupyter Notebook support "sphinx_copybutton", # add copy button to code blocks + "sphinx_thebe", # make code blocks executable in the browser using Thebe ] # https://myst-nb.readthedocs.io/en/latest/computation/execute.html @@ -86,6 +87,10 @@ # "matplotlib": ("https://matplotlib.org/stable/", None), } +# thebe options +# https://sphinx-thebe.readthedocs.io +thebe_config = {"selector": "div.highlight"} # makes ALL code cells runnable + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -97,8 +102,8 @@ # html_logo = "_static/logo-wide.svg" # html_favicon = "_static/logo-square.svg" html_theme_options = { - "github_url": "https://github.com/RasmussenLab/python_package", - "repository_url": "https://github.com/RasmussenLab/python_package", + "github_url": "https://github.com/biosustain/python_package", + "repository_url": "https://github.com/biosustain/python_package", "repository_branch": "main", "home_page_in_toc": True, "path_to_docs": "docs", @@ -107,9 +112,10 @@ "use_repository_button": True, "use_download_button": True, "launch_buttons": { - "colab_url": "https://colab.research.google.com" - # "binderhub_url": "https://mybinder.org", - # "notebook_interface": "jupyterlab", + "colab_url": "https://colab.research.google.com", + "binderhub_url": "https://mybinder.org", + "notebook_interface": "jupyterlab", + "thebe": True, }, "navigation_with_keys": False, } From 5868136226bc05c7832d044c28d497ab941ba2ca Mon Sep 17 00:00:00 2001 From: "Angel L. P." <59593766+angelphanth@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:32:38 +0200 Subject: [PATCH 3/5] :memo: init docs for interactive notebook options --- docs/README.md | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/docs/README.md b/docs/README.md index 2100887..95efc6c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,3 +30,92 @@ sphinx-apidoc --force --implicit-namespaces --module-first -o reference ../src/p # build docs sphinx-build -n -W --keep-going -b html ./ ./_build/ ``` + +## Interactive notebooks + +### colab +- google product so requires users to have a google account +- does not set up the env automatically so in your notebook include commands for installing dependencies e.g. + ```python + # for colab + !pip install python_package + ``` + +#### Setup +- configure launch_buttons in html_theme_options +- for example: + ```python + html_theme_options = { + ... + "launch_buttons": { + ... + "colab_url": "https://colab.research.google.com", + } + ``` + +### binder +- doesn't require users to install things into env like colab does + +#### Setup +- have repository_url and branch in html_theme_options of conf.py +- also configure launch_buttons in html_theme_options + - [mybinder.org](https://jupyter.org/binder#binderhub) is a free service + - or [deploy your own?](https://jupyter.org/binder#binderhub) +- for example: + ```python + html_theme_options = { + ... + "repository_url": "https://github.com/biosustain/python_package", + "repository_branch": "main", + "launch_buttons" : { + ... + "binderhub_url": "https://mybinder.org", + "notebook_interface": "jupyterlab", + } + } + ``` + + +### thebe +- relies on binder +- turns notebooks to interactive code cells in the docs in the browser. + +#### Extra Requirements +- installation of [`sphinx-thebe`](https://sphinx-thebe.readthedocs.io/en/latest/) e.g. add sphinx-thebe to docs group of [pyproject.toml](../pyproject.toml) + +#### Setup +- configure thebe in html_theme_options in [conf.py](conf.py) + ```python + html_theme_options = { + ... + # for binder which is used by thebe + "repository_url": "https://github.com/biosustain/python_package", + "repository_branch": "main", + "launch_buttons" : { + ... + "thebe": True + } + } + ``` + - instead can configure thebe repository url and branch in `thebe_config` +- the `selector` in `thebe_config` tells thebe what html element to search for to tun into a runnable code cell +- if wanting to make all code cells runnable set `selector` to `