Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
agriyakhetarpal wants to merge37 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromagriyakhetarpal:add_replite_docs_reprise
Open
Show file tree
Hide file tree
Changes from25 commits
Commits
Show all changes
37 commits
Select commitHold shift + click to select a range
fae43c3
Add replite console to the users docs
martinRenouMar 10, 2022
e5ecaac
Update gallery and add link to the JupyterLite deployment
martinRenouJul 26, 2022
2374f55
Use latest jupyterlite-xeus-python
martinRenouAug 5, 2022
7c75115
Use recursive glob for the content
martinRenouAug 16, 2022
c92ca21
JupyterLite dependencies now available with conda-forge
agriyakhetarpalJan 16, 2025
47b4b42
Move gallery sentence below the REPL iframe
agriyakhetarpalJan 16, 2025
251ab4b
Disable Pyodide kernel, Xeus is already configured
agriyakhetarpalJan 21, 2025
5194b89
Disable `rstcheck` for Replite directive
agriyakhetarpalJan 21, 2025
7c7dce7
Ignore unintended Jupytext/Sphinx-Gallery warning
agriyakhetarpalJan 21, 2025
9786561
Ignore JupyterLite contents and doit file
agriyakhetarpalJan 21, 2025
ede0d71
Remove JupyterLite contents with `make clean`
agriyakhetarpalJan 21, 2025
0faaf52
Add missing environment, fix JupyterLite builds
agriyakhetarpalJan 21, 2025
5ebdd52
Fix the REPL's size and formatting
agriyakhetarpalJan 21, 2025
a26fbf3
Disable Sphinx-Gallery's JupyterLite integration for now
agriyakhetarpalJan 21, 2025
2ccd369
Drop `XeusPythonEnv` for env file, add WASM deps
agriyakhetarpalJan 22, 2025
3601e38
Optimise JupyterLite for build size
agriyakhetarpalJan 22, 2025
3e08f5f
Add note about Xeus environment file
agriyakhetarpalJan 22, 2025
f74bec7
Fix: incorrect kernel name
agriyakhetarpalJan 22, 2025
5422940
Use `kbd` directive for highlighting keys
agriyakhetarpalJan 22, 2025
22ce559
Mark live example as "experimental"
agriyakhetarpalJan 23, 2025
34611e1
Add gallery contents to JupyterLite deployment
agriyakhetarpalJan 23, 2025
c170ede
Missing kernel, add xeus-python
agriyakhetarpalJan 23, 2025
3078611
Add custom storage name
agriyakhetarpalJan 23, 2025
5ec29f3
Properly ignore extra contents
agriyakhetarpalJan 23, 2025
759f78c
Silence JupyterLite now that we're done
agriyakhetarpalJan 23, 2025
4fed028
Debug: un-silence JupyterLite build
agriyakhetarpalJan 23, 2025
d8d63da
Pin NumPy to <2
agriyakhetarpalJan 23, 2025
cf3a737
Reminder for silencing JupyterLite
agriyakhetarpalJan 23, 2025
3faa465
Move the REPL to Gallery intro page
agriyakhetarpalJan 23, 2025
451ae62
Don't ignore JupyterLite env file from linting
agriyakhetarpalJan 24, 2025
86a5f7c
Link to Jupytext-related jupyterlite-sphinx issue
agriyakhetarpalJan 24, 2025
55fe769
Don't update MEP-12
agriyakhetarpalJan 24, 2025
f0d4de4
Remove REPL from galleries page
agriyakhetarpalJan 24, 2025
6ad6e46
Try installing `pip` packages into a venv
agriyakhetarpalJan 24, 2025
94e4246
Activate venv before docs build
agriyakhetarpalJan 24, 2025
260d3d7
Revert "Activate venv before docs build"
agriyakhetarpalJan 27, 2025
a60b9d0
Revert "Try installing `pip` packages into a venv"
agriyakhetarpalJan 27, 2025
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
13 changes: 13 additions & 0 deletions.circleci/config.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,6 +94,16 @@ commands:
python -m pip install --upgrade --user wheel
python -m pip install --upgrade --user 'setuptools!=60.6.0'

mamba-install:
description: Install micromamba so it can be used for building the emscripten-forge environment
steps:
- run:
name: Install micromamba
command: |
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
pwd
ls

doc-deps-install:
parameters:
numpy_version:
Expand DownExpand Up@@ -138,6 +148,8 @@ commands:
- run:
name: Build documentation
command: |
export PATH="$(pwd)/../bin:$PATH"
echo $PATH
# Set epoch to date of latest tag.
export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))"
# Set release mode only when deploying to devdocs.
Expand DownExpand Up@@ -228,6 +240,7 @@ jobs:
- apt-install
- fonts-install
- pip-install
- mamba-install

- doc-deps-install
- mpl-install
Expand Down
4 changes: 4 additions & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,3 +124,7 @@ lib/matplotlib/backends/web_backend/node_modules/
lib/matplotlib/backends/web_backend/package-lock.json

LICENSE/LICENSE_QHULL

# JupyterLite
.jupyterlite.doit.db
/doc/jupyterlite_contents
3 changes: 3 additions & 0 deletions.yamllint.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
---
extends:default

ignore:|
doc/jupyterlite_environment.yml
rules:
line-length:
max:120
Expand Down
2 changes: 2 additions & 0 deletionsdoc/Makefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,8 @@ clean:
rm -rf "$(SOURCEDIR)/sphinxext/__pycache__"
rm -f $(SOURCEDIR)/_static/constrained_layout*.png
rm -f $(SOURCEDIR)/sg_execution_times.rst
rm -rf $(SOURCEDIR)/jupyterlite_contents
rm -rf $(SOURCEDIR)/.jupyterlite.doit.db

show:
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(shell pwd)/build/html/index.html')"
Expand Down
32 changes: 31 additions & 1 deletiondoc/conf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,15 @@ 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
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 = [
Expand All@@ -128,7 +137,7 @@ def _parse_skip_subdirs_file():
'sphinxext.redirect_from',
'sphinx_copybutton',
'sphinx_design',
'sphinx_tags',
'jupyterlite_sphinx',
]

exclude_patterns = [
Expand DownExpand Up@@ -305,6 +314,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'):
Expand DownExpand Up@@ -767,6 +780,23 @@ def js_tag_with_cache_busting(js):
1),
]

# JupyterLite config
Copy link
Member

Choose a reason for hiding this comment

The 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 itcould be negligible for all I know.

Copy link
Author

@agriyakhetarpalagriyakhetarpalJan 24, 2025
edited
Loading

Choose a reason for hiding this comment

The 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 withhtml-noplot at this time, so it would even lesser of a fraction with CI builds which would be longer.

But to answer whether this can be disabled, I can check for theDEVDOCS andis_release_build constants so that this is avoided on local builds, as this concern was also raised from the perspective of downstream packagers in the older PR#22634. It could make debugging a build that's failing in CI a bit of a pain, though.

Copy link
Member

Choose a reason for hiding this comment

The 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 = True
jupyterlite_build_command_options = {
"XeusAddon.environment_file": "jupyterlite_environment.yml",
}


# numpydoc config

numpydoc_show_class_members = False
Expand Down
23 changes: 23 additions & 0 deletionsdoc/index.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,6 +99,29 @@ Learn
- figures: `.pyplot.figure`
- subplots: `.pyplot.subplots`, `.pyplot.subplot_mosaic`

Live example (experimental)
===========================

Try Matplotlib directly in this documentation (press :kbd:`shift` + :kbd:`Enter` to execute code)!

.. rstcheck: ignore-directives=replite
.. replite::
:kernel: xeus-python
:height: 600px
:prompt: Try Matplotlib!
:execute: False

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
plt.plot(np.sin(np.linspace(0, 20, 100)))
plt.show();

Alternatively, you can try the gallery examples in `our JupyterLite deployment <./lite/lab>`__.

Community
=========

Expand Down
10 changes: 10 additions & 0 deletionsdoc/jupyter-lite.json
View file
Open in desktop
Original file line numberDiff line numberDiff 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"
}
}
7 changes: 7 additions & 0 deletionsdoc/jupyter_lite_config.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why is there ajupyter-lite.json andjupyter_lite_config.json? These seem redundantly (or at least non-descriptively) named.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The JupyterLite CLI is atraitlets based app, sojupyter_lite_config.json follows the naming convention as other apps, likevoila.json orjupyter_server_config.json. It is indeed for build time configuration (when running the JupyterLite CLI, for example withjupyter lite build).

jupyter-lite.json is for runtime configuration when loading the page. It is similar to thepage_config.json used in JupyterLab.

Agree this can be confusing. Maybe JupyterLite could also support loadingpage_config.json files so users could choose a different name for the file?

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
}
}
15 changes: 15 additions & 0 deletionsdoc/jupyterlite_environment.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
# 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
- numpy
- matplotlib
- ipympl
# a kernel for running them
- xeus-python
2 changes: 2 additions & 0 deletionsenvironment.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,6 +43,8 @@ dependencies:
- joblib # needed for sphinx-gallery[parallel]
- sphinx-design
- sphinx-tags>=0.4.0
- jupyterlite-sphinx>=0.18.0
- jupyterlite-xeus>=3.0.2
- pystemmer
- pip
- pip:
Expand Down
2 changes: 2 additions & 0 deletionsrequirements/doc/doc-requirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,3 +24,5 @@ sphinx-copybutton
sphinx-design
sphinx-gallery[parallel]>=0.12.0
sphinx-tags>=0.4.0
jupyterlite-sphinx>=0.18.0
jupyterlite-xeus>=3.0.2
Loading

[8]ページ先頭

©2009-2025 Movatter.jp