Sphinx extension for embedding Marimo notebooks with WASM support
Project description
sphinx-marimo
A Sphinx extension for embedding interactive Marimo notebooks in documentation with WASM support, similar to Jupyter-Lite.
Installation
Using uv (recommended):
uv add sphinx-marimo
Or using pip:
pip install sphinx-marimo
Quick Start
- Add the extension to your
conf.py:
extensions = [
'sphinx_marimo',
# ... other extensions
]
# Optional configuration
marimo_notebook_dir = 'notebooks' # Directory containing .py Marimo notebooks
marimo_default_height = '600px'
marimo_default_width = '100%'
- Create a Marimo notebook (
.pyfile):
import marimo
__generated_with = "0.1.0"
app = marimo.App()
@app.cell
def __():
import marimo as mo
return mo,
@app.cell
def __(mo):
slider = mo.ui.slider(1, 10, value=5)
mo.md(f"Value: {slider.value}")
return slider,
- Embed it in your documentation:
.. marimo:: path/to/notebook.py
:height: 800px
:width: 100%
Sphinx Gallery Integration
The extension automatically detects Sphinx Gallery and adds "launch marimo" buttons:
# In conf.py
extensions = [
'sphinx_gallery.gen_gallery', # Must come before sphinx_marimo
'sphinx_marimo',
]
sphinx_gallery_conf = {
'examples_dirs': '../gallery_examples',
'gallery_dirs': 'auto_examples',
}
# Customize button text (optional)
marimo_gallery_button_text = 'launch marimo'
Gallery examples will automatically include red "launch marimo" buttons alongside existing Binder/JupyterLite buttons.
Architecture
The extension works by:
- Build Phase: Converting Marimo
.pynotebooks to WASM during Sphinx build - Runtime: Serving notebooks as static files that run in the browser
- Gallery Integration: Converting Gallery-generated
.ipynbfiles to Marimo WASM - UI Integration: Injecting launcher buttons into Gallery pages
Examples
See the documentation for live examples and full usage guide.
Requirements
- Python 3.8+
- Sphinx 4.0+
- Marimo 0.1.0+
- For Gallery integration: sphinx-gallery 0.10+
Development
git clone https://github.com/your-repo/sphinx-marimo
cd sphinx-marimo
uv venv
uv pip install -e .
License
MIT License - see LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_marimo-0.2.3.tar.gz.
File metadata
- Download URL: sphinx_marimo-0.2.3.tar.gz
- Upload date:
- Size: 142.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2ba626579e8e1163d38052745bc607cacdf37252e36fc4ca7e6dd8ec12930f
|
|
| MD5 |
dc3faa6eaf015d05d0d3df880921ac46
|
|
| BLAKE2b-256 |
774fa3376d6b2bd10b52731da4957e25a4ab0273aa46d42261c4afca13941b15
|
File details
Details for the file sphinx_marimo-0.2.3-py3-none-any.whl.
File metadata
- Download URL: sphinx_marimo-0.2.3-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97a7f68e56d22c43032af7d67c5fd74a638eaca031f62c73e9c38b4fe921c08d
|
|
| MD5 |
b86a2acbbd3ab900ffbc94d7186d01f7
|
|
| BLAKE2b-256 |
9240c719a25619b4fb146d754258162abbbf4f321bd506f12690f86b9d3ffea2
|