Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/jupyterlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build JupyterLite

on: # yamllint disable-line rule:truthy
push:
branches:
- jupyterlite-gh-actions

permissions:
contents: read

jobs:
build:
name: Build JupyterLite Site
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install JupyterLite & Build Tools
run: |
python -m pip install --upgrade pip
pip install jupyterlite-core jupyterlite-pyodide-kernel build jupyter-server

- name: Build MNE-Python Wheel
run: |
python -m build --wheel
mkdir -p lite-wheels
cp dist/*.whl lite-wheels/

- name: Build JupyterLite Site
# We pass the local wheel to JupyterLite so the browser environment uses the exact code from this branch!
run: |
jupyter lite build --contents examples/ --output-dir dist_lite/ --piplite-wheel lite-wheels/*.whl

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: jupyterlite-build
path: dist_lite/
1 change: 1 addition & 0 deletions doc/changes/dev/13925.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a JupyterLite GitHub Actions workflow to automatically build a Wasm-compatible interactive documentation site by Natneal Belete.
24 changes: 24 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
# contrib
"matplotlib.sphinxext.plot_directive",
"numpydoc",
"jupyterlite_sphinx",
"sphinx_copybutton",
"sphinx_design",
"sphinx_gallery.gen_gallery",
Expand Down Expand Up @@ -473,6 +474,29 @@

sphinx_gallery_parallel = int(os.getenv("MNE_DOC_BUILD_N_JOBS", "1"))
sphinx_gallery_conf = {
"jupyterlite": {
"use_jupyter_lab": True,
},
"first_notebook_cell": (
"# 💡 This cell is automatically added to the start of each notebook.\n"
"import micropip\n"
"await micropip.install(['mne', 'pyodide-http'])\n"
"\n"
"# 1. Patch networking so pooch can download datasets\n"
"import pyodide_http\n"
"pyodide_http.patch_all()\n"
"\n"
"# 2. Patch MNEBrowseFigure to auto-display in Pyodide's inline backend\n"
"import mne\n"
"import mne.viz.utils\n"
"import matplotlib.pyplot as plt\n"
"orig_plt_show = mne.viz.utils.plt_show\n"
"def pyodide_plt_show(fig=None, **kwargs):\n"
" orig_plt_show(fig, **kwargs)\n"
" import IPython.display\n"
" IPython.display.display(plt.gcf())\n"
"mne.viz.utils.plt_show = pyodide_plt_show\n"
),
"doc_module": ("mne",),
"reference_url": dict(mne=None),
"examples_dirs": examples_dirs,
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ doc = [
"graphviz",
"intersphinx_registry >= 0.2405.27",
"ipython != 8.7.0", # also in "full-no-qt" and "test"
"jupyterlite-pyodide-kernel",
"jupyterlite-sphinx",
"memory_profiler >= 0.16",
"mne-bids",
"mne-connectivity",
Expand Down
Loading