Sphinx Thebe is a Sphinx extension that integrates interactive code blocks into documentation using Thebe.js and Binder. It allows readers to execute code examples directly in their browser against a live Jupyter kernel. The current version is 0.3.1, with releases occurring periodically to address Sphinx compatibility and feature enhancements.
pip install sphinx-thebeVerified import paths — ran on the pinned version, not inferred.
To quickly get started, install the package, then add `sphinx_thebe` to your `conf.py` extensions list. Crucially, define a `thebe_config` dictionary specifying your BinderHub URL and kernel details. Finally, use the `thebe-button` directive followed by a code block in your reStructuredText or MyST Markdown files.
Ensure `thebe_config` in `conf.py` has valid `binderhub_url` and `repository_url` pointing to a compatible Binder repository. For example: `binderhub_url: 'https://mybinder.org', repository_url: 'https://github.com/binder-examples/jupyter-stacks-datascience'`.
To force eager loading, set `'always_load': true` in your `thebe_config` dictionary in `conf.py`. Be aware this increases initial page load time.
Review custom frontend scripts after upgrading `sphinx-thebe` to ensure compatibility with updated internal dependencies. Test thoroughly, especially if you're injecting custom JavaScript into Thebe's components.
Clearly communicate the source of the interactive kernels and any associated security considerations in your documentation.