Skip to main content

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

  1. 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%'
  1. Create a Marimo notebook (.py file):
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,
  1. 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:

  1. Build Phase: Converting Marimo .py notebooks to WASM during Sphinx build
  2. Runtime: Serving notebooks as static files that run in the browser
  3. Gallery Integration: Converting Gallery-generated .ipynb files to Marimo WASM
  4. 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

sphinx_marimo-0.2.3.tar.gz (142.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_marimo-0.2.3-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

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

Hashes for sphinx_marimo-0.2.3.tar.gz
Algorithm Hash digest
SHA256 0e2ba626579e8e1163d38052745bc607cacdf37252e36fc4ca7e6dd8ec12930f
MD5 dc3faa6eaf015d05d0d3df880921ac46
BLAKE2b-256 774fa3376d6b2bd10b52731da4957e25a4ab0273aa46d42261c4afca13941b15

See more details on using hashes here.

File details

Details for the file sphinx_marimo-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_marimo-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 97a7f68e56d22c43032af7d67c5fd74a638eaca031f62c73e9c38b4fe921c08d
MD5 b86a2acbbd3ab900ffbc94d7186d01f7
BLAKE2b-256 9240c719a25619b4fb146d754258162abbbf4f321bd506f12690f86b9d3ffea2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page