-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: Add a JupyterLite-powered REPL to the Matplotlib documentation's landing page, and enable interactive galleries #29506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fae43c3
e5ecaac
2374f55
7c75115
c92ca21
47b4b42
251ab4b
5194b89
7c7dce7
9786561
ede0d71
0faaf52
5ebdd52
a26fbf3
2ccd369
3601e38
3e08f5f
f74bec7
5422940
22ce559
34611e1
c170ede
3078611
5ec29f3
759f78c
4fed028
d8d63da
cf3a737
3faa465
451ae62
86a5f7c
55fe769
f0d4de4
6ad6e46
94e4246
260d3d7
a60b9d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,16 @@ def _parse_skip_subdirs_file(): | |
# usage in the gallery. | ||
warnings.filterwarnings('error', append=True) | ||
|
||
# Prevent Sphinx-Gallery and jupytext incompatibility warning. This is spurious | ||
# and can be ignored for our use case. This has to be added before importing | ||
# jupyterlite_sphinx below, so that we can block the warning before it is raised. | ||
# TODO: Fix this in jupyterlite-sphinx | ||
# https://github.com/jupyterlite/jupyterlite-sphinx/issues/258 | ||
warnings.filterwarnings('ignore', category=UserWarning, | ||
message=( | ||
r'(\n|.)*Sphinx Gallery in version 0.18.0 is not ' | ||
r'supported by Jupytext')) | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. | ||
extensions = [ | ||
|
@@ -128,7 +138,7 @@ def _parse_skip_subdirs_file(): | |
'sphinxext.redirect_from', | ||
'sphinx_copybutton', | ||
'sphinx_design', | ||
'sphinx_tags', | ||
'jupyterlite_sphinx', | ||
] | ||
|
||
exclude_patterns = [ | ||
|
@@ -305,6 +315,10 @@ def autodoc_process_bases(app, name, obj, options, bases): | |
'within_subsection_order': gallery_order_subsectionorder, | ||
'capture_repr': (), | ||
'copyfile_regex': r'.*\.rst', | ||
# Disable Sphinx-Gallery's JupyterLite integration until there's | ||
# further notice. It comes from our usage of jupyterlite-sphinx | ||
# as a registered extension. | ||
'jupyterlite': None, | ||
} | ||
|
||
if parse_version(sphinx_gallery.__version__) >= parse_version('0.17.0'): | ||
|
@@ -767,6 +781,23 @@ def js_tag_with_cache_busting(js): | |
1), | ||
] | ||
|
||
# JupyterLite config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way this can be disabled by default and enabled by a flag? This could be set on CI and in release mode. I'm not sure we want to be paying the build costs locally for every developer. But since the build failed, I'm not sure exactly how large that build time cost is, so it could be negligible for all I know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The build time cost is around ~15 seconds for me locally, which seems negligible in comparison to the rest of the docs build – I've been building with But to answer whether this can be disabled, I can check for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, let's see how long it ends up taking first. |
||
|
||
jupyterlite_bind_ipynb_suffix = False | ||
# Include the gallery examples in the JupyterLite deployment. | ||
# .zip,.png,.gif, .json and other extra file formats generated by | ||
# Sphinx-Gallery are ignored via the LiteBuildConfig/extra_ignore_contents | ||
# key in the jupyter_lite_config.json file. | ||
jupyterlite_contents = ["gallery/**"] | ||
# Set this to False to aid debugging locally or in CI. It is silenced | ||
# by default as there is no way to disable the JupyterLite output in | ||
# parts right now, and it can be quite verbose. | ||
jupyterlite_silence = False # set to False when merging | ||
jupyterlite_build_command_options = { | ||
"XeusAddon.environment_file": "jupyterlite_environment.yml", | ||
} | ||
|
||
|
||
# numpydoc config | ||
|
||
numpydoc_show_class_members = False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"jupyter-lite-schema-version": 0, | ||
"jupyter-config-data": { | ||
"disabledExtensions": [ | ||
"@jupyterlite/javascript-kernel-extension", | ||
"@jupyterlite/pyodide-kernel-extension" | ||
], | ||
"contentsStorageName": "JupyterLite Matplotlib Docs Storage" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've always been confused about this myself. One is for the CLI, one is for the JupyterLite frontend. The naming is pretty bad. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JupyterLite CLI is a
Agree this can be confusing. Maybe JupyterLite could also support loading For more information: https://jupyterlite.readthedocs.io/en/stable/howto/configure/config_files.html |
||
"LiteBuildConfig": { | ||
"extra_ignore_contents": ["\\.(rst|zip|pickle|py|json|svg|md5|png|gif)"], | ||
"no_unused_shared_packages": true, | ||
"no_sourcemaps": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This environment file is added via the XeusAddon.environment_file | ||
# key in the jupyterlite_build_command_options dict in conf.py. See | ||
# https://jupyterlite-sphinx.readthedocs.io/en/stable/configuration.html | ||
# for more information on additional configuration options. | ||
--- | ||
|
||
name: mpl-wasm-docs | ||
channels: | ||
- https://repo.mamba.pm/emscripten-forge | ||
- conda-forge | ||
dependencies: | ||
# for examples in the gallery | ||
# temporary: pin NumPy to <2 for now, see https://github.com/emscripten-forge/recipes/issues/1766 | ||
- numpy==1.26.4 | ||
- matplotlib | ||
- ipympl | ||
# a kernel for running them | ||
- xeus-python |
Uh oh!
There was an error while loading. Please reload this page.