Skip to content

Commit df8656d

Browse files
ENH: Integrate jupyterlite-sphinx for examples
1 parent f1544c4 commit df8656d

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

doc/conf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
# contrib
113113
"matplotlib.sphinxext.plot_directive",
114114
"numpydoc",
115+
"jupyterlite_sphinx",
115116
"sphinx_copybutton",
116117
"sphinx_design",
117118
"sphinx_gallery.gen_gallery",
@@ -470,6 +471,28 @@
470471

471472
sphinx_gallery_parallel = int(os.getenv("MNE_DOC_BUILD_N_JOBS", "1"))
472473
sphinx_gallery_conf = {
474+
"jupyterlite": {
475+
"use_jupyter_lab": True,
476+
},
477+
"first_notebook_cell": (
478+
"# 💡 This cell is automatically added to the start of each notebook.\n"
479+
"import micropip\n"
480+
"await micropip.install(['mne', 'pyodide-http'])\n"
481+
"\n"
482+
"# 1. Patch networking so pooch can download datasets\n"
483+
"import pyodide_http\n"
484+
"pyodide_http.patch_all()\n"
485+
"\n"
486+
"# 2. Patch MNEBrowseFigure to auto-display in Pyodide's inline backend\n"
487+
"import mne\n"
488+
"import matplotlib.pyplot as plt\n"
489+
"orig_plt_show = mne.viz.utils.plt_show\n"
490+
"def pyodide_plt_show(fig=None, **kwargs):\n"
491+
" orig_plt_show(fig, **kwargs)\n"
492+
" import IPython.display\n"
493+
" IPython.display.display(plt.gcf())\n"
494+
"mne.viz.utils.plt_show = pyodide_plt_show\n"
495+
),
473496
"doc_module": ("mne",),
474497
"reference_url": dict(mne=None),
475498
"examples_dirs": examples_dirs,

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ doc = [
99
"graphviz",
1010
"intersphinx_registry >= 0.2405.27",
1111
"ipython != 8.7.0", # also in "full-no-qt" and "test"
12+
"jupyterlite-pyodide-kernel",
13+
"jupyterlite-sphinx",
1214
"memory_profiler >= 0.16",
1315
"mne-bids",
1416
"mne-connectivity",

0 commit comments

Comments
 (0)