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%

Click-to-Load Feature

Marimo notebooks use WASM which can be compute-intensive. The extension offers multiple loading modes to optimize performance and user experience:

Loading Modes

# In conf.py
marimo_click_to_load = True  # Can be: False, True/"overlay", or "compact"
marimo_load_button_text = "Load Interactive Notebook"  # Customize button text

Available Modes:

  1. Immediate Loading (False) - Traditional behavior, notebooks load immediately
  2. Overlay Mode (True or "overlay") - Full-height overlay with centered button (default)
  3. Compact Mode ("compact") - Space-saving button that expands when clicked

Per-Notebook Configuration

Override the global setting for individual notebooks:

# Compact mode - saves screen space
.. marimo:: heavy_computation.py
   :click-to-load: compact
   :load-button-text: Run Analysis

# Overlay mode - full height with centered button
.. marimo:: demo.py
   :click-to-load: overlay
   :load-button-text: Start Demo

# Immediate loading - no button
.. marimo:: quick_example.py
   :click-to-load: false

Use Cases:

  • Compact mode: Perfect for documentation with multiple notebooks on one page
  • Overlay mode: Best for standalone demos where the notebook is the focus
  • Immediate loading: Ideal for lightweight, essential notebooks

This flexibility allows you to optimize for:

  • Better page load times on mobile devices
  • Reduced bandwidth for users who don't interact with every notebook
  • Improved user experience with progressive disclosure

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. Click-to-Load: Deferring notebook loading until user interaction for better performance

Examples

See the documentation for live examples and full usage guide.

Requirements

  • Python 3.8+
  • Sphinx 4.0+
  • Marimo 0.1.0+

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.3.0.tar.gz (271.8 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.3.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_marimo-0.3.0.tar.gz.

File metadata

  • Download URL: sphinx_marimo-0.3.0.tar.gz
  • Upload date:
  • Size: 271.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sphinx_marimo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e27883a673868b53140789b31674bc19c59a8122e9eea0267ca6c15fd9f72f17
MD5 139976eda2230940516f933137b92981
BLAKE2b-256 daa2d6c6c025da4813ea3f736a089a052ff2c6d4ab727abf8331ed4e80b062e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sphinx_marimo-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sphinx_marimo-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 205fca3aed0607d480fa9c3baafdd038fc85b899077793b04444beaa30356122
MD5 b25c83742c530b6e59aba9531b01511f
BLAKE2b-256 979cd2141e67a51256c80f2f1879602c010e9a0f6002913edfd3012e8e112891

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