Skip to content
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c28aab1
configure `jupyterlite-sphinx`' `try_examples` feature
keewis May 8, 2025
774d613
set a minimum height
keewis May 8, 2025
a63ace9
[skip-ci]
keewis May 8, 2025
bac77ee
Merge branch 'main' into jupyterlite
keewis May 8, 2025
4c0a096
[skip-ci]
keewis May 8, 2025
438b597
bad merge [skip-ci]
keewis May 8, 2025
3dc3abe
add `jupyterlite-sphinx` to the env [skip-ci][skip-rtd]
keewis May 8, 2025
807fd69
also install the pyodide kernel
keewis May 8, 2025
31a6db6
ignore the `_contents` directory created by `jupyterlite-sphinx`
keewis May 8, 2025
28afda4
[skip-ci]
keewis May 8, 2025
5d2ca4e
Merge branch 'main' into jupyterlite
keewis May 8, 2025
a4d1285
[skip-ci]
keewis May 8, 2025
f798349
add a `try_examples` preamble as a function
keewis Sep 19, 2025
d963012
Merge branch 'main' into jupyterlite
keewis Sep 19, 2025
c5146e4
use the new name for the document
keewis Sep 19, 2025
d5b8be4
Merge branch 'main' into jupyterlite
keewis Sep 30, 2025
f87e460
Merge branch 'main' into jupyterlite
dcherian Oct 18, 2025
1be41f4
change the preamble to text
keewis Feb 16, 2026
ff16169
Merge branch 'main' into jupyterlite
keewis Feb 16, 2026
69bee86
add `jupyterlite-sphinx` and `jupyterlite-xeus` to the doc deps
keewis Feb 16, 2026
c9ed2b4
ignore the generated files
keewis Feb 18, 2026
b9ccc3d
bump sphinx
keewis Feb 18, 2026
092d570
bump jupyterlite-sphinx
keewis Feb 18, 2026
8e176dd
task to prepare the local env
keewis Feb 18, 2026
4063847
task to create the local noarch package
keewis Feb 18, 2026
395ed4f
typos
keewis Feb 18, 2026
cc352d9
enable concurrent builds
keewis Feb 18, 2026
74f5759
combined task to debug the docs without autobuilding
keewis Feb 18, 2026
115a95a
unsilence jupyterlite
keewis Feb 18, 2026
17b06a3
make sure `_contents` exists
keewis Feb 18, 2026
5468ea9
add the missing environment creation files
keewis Feb 18, 2026
bcd69bb
strip whitespace around the preamble
keewis Feb 18, 2026
ccf60cc
explicitly build the conda package
keewis Feb 19, 2026
7a2ffc3
Merge branch 'main' into jupyterlite
keewis Feb 19, 2026
7654f0a
correct the listed path
keewis Feb 19, 2026
5c1e2a1
print the path of the `_contents` directory
keewis Feb 19, 2026
ea4a483
don't exclude the `_contents` directory
keewis Feb 19, 2026
35895ca
remove the creation of the `_contents` directory
keewis Feb 19, 2026
e999e05
changelog
keewis Feb 19, 2026
587cbda
Merge branch 'main' into jupyterlite
keewis Feb 19, 2026
5aa53ad
clean up the `jupyter_execute` directory, as well
keewis Feb 24, 2026
d5f75bd
Merge branch 'main' into jupyterlite
keewis Feb 24, 2026
9bb47c6
ignore the `_contents` directory
keewis Feb 24, 2026
d8504a3
try setting `jupyterlite_bind_ipynb_suffix` instead
keewis Feb 25, 2026
53f8eed
Merge branch 'main' into jupyterlite
keewis Mar 8, 2026
e5aa1cb
Merge branch 'main' into jupyterlite
keewis Jul 27, 2026
37788c4
specify the contents path for jupyterlite-sphinx
keewis Jul 28, 2026
327b99d
use vcs-versioning to infer the version with the same tools as the bu…
keewis Jul 28, 2026
335e33b
rename the config value
keewis Jul 28, 2026
c261bff
use a custom version of `jupyterlite-sphinx`
keewis Jul 28, 2026
7bef894
include the `numba` feature in the docs
keewis Jul 28, 2026
9dae51d
include the new channel at the top level
keewis Jul 28, 2026
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ doc/videos-gallery.txt
doc/*.zarr
doc/*.nc
doc/*.h5
doc/_contents/
.virtual_documents/
.jupyterlite.doit.db

# Until we support this properly, excluding from gitignore. (adding it to
# gitignore to make it _easier_ to work with `uv`, not as an indication that I
Expand All @@ -98,3 +101,6 @@ xarray-docs/
# pixi environments
.pixi
pixi.lock
# recipe
/ci/recipe/recipe.yaml
/doc/environment.yml
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ build:
- pixi install --concurrent-solves 2 -e doc
build:
html:
- pixi run build
- pixi run doc BUILDDIR=$READTHEDOCS_OUTPUT
42 changes: 42 additions & 0 deletions ci/recipe/prepare_recipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

import pathlib
import textwrap

import git
import packaging.version
from tlz.itertoolz import last


def dev_version(most_recent_release):
v = packaging.version.parse(str(most_recent_release))

next_version = (v.major, v.minor, v.micro + 1)
return str(v.__replace__(release=next_version, dev=0))


def main():
repo = git.Repo(".")
root = pathlib.Path(repo.working_dir)

most_recent_release = last(list(repo.tags))
version = dev_version(most_recent_release)
recipe_root = root / "ci/recipe"

template_path = recipe_root / "recipe_template.yaml"
template = template_path.read_text()

context = textwrap.dedent(
f"""\
context:
name: xarray
version: {version}
""".rstrip()
)
recipe = "\n".join([context, "", template]) # noqa: FLY002
recipe_path = recipe_root / "recipe.yaml"
recipe_path.write_text(recipe)


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions ci/recipe/recipe_template.yaml

@VeckoTheGecko VeckoTheGecko Feb 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re. naming, perhaps ci/rattler/recipe.yaml and ci/rattler/prepare_recipe.py is clearer ?

(EDIT: This is a nit)

@keewis keewis Feb 19, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was hoping to at some point get rid of the recipe in favor of using the output of pixi build with the python backend, we'd just need to get the version to work properly (I copied this from healpix-geo, where I had to use rattler directly because I need to compile rust code to emscripten-wasm32).

Edit: in the meantime the rename sounds fine to me.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package:
name: ${{ name }}
version: ${{ version }}

source:
path: ../..

build:
number: 0
noarch: python
script: SETUPTOOLS_SCM_PRETEND_VERSION=${{ version }} ${{ PYTHON }} -m pip install -vvv . --no-deps --no-build-isolation

files:
exclude:
- "**/__pycache__/**"
- "**/*.pyc"
- "**/test_*.py"
python:
skip_pyc_compilation:
- "**/*.py"

requirements:
build:
- python
host:
- python
- pip
- setuptools
- setuptools-scm
run:
- python
- numpy
- pandas
- packaging

about:
summary: N-D labeled arrays and datasets in Python
license: Apache-2.0
license_file: LICENSE
homepage: https://github.com/pydata/xarray
repository: https://github.com/pydata/xarray
8 changes: 4 additions & 4 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = -j auto
SPHINXBUILD = sphinx-build
SPHINXATUOBUILD = sphinx-autobuild
SPHINXAUTOBUILD = sphinx-autobuild
PAPER =
BUILDDIR = _build

Expand Down Expand Up @@ -68,8 +68,8 @@ rtdhtml:

.PHONY: livehtml
livehtml:
# @echo "$(SPHINXATUOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html"
$(SPHINXATUOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
# @echo "$(SPHINXAUTOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html"
$(SPHINXAUTOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

.PHONY: dirhtml
dirhtml:
Expand Down
21 changes: 18 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"sphinx_design",
"sphinx_inline_tabs",
"sphinx_remove_toctrees",
"jupyterlite_sphinx",
"sphinx_llm.txt",
]

Expand Down Expand Up @@ -173,17 +174,31 @@
"pd.Index": "~pandas.Index",
"pd.NaT": "~pandas.NaT",
}

autodoc_type_aliases = napoleon_type_aliases # Keep both in sync

# jupyterlite try_examples config
global_enable_try_examples = True
try_examples_global_button_text = "Try it in your browser!"
try_examples_global_warning_text = "Interactive examples are experimental and may not always work as expected."

try_examples_preamble = """
import numpy as np
import pandas as pd
import xarray as xr

np.random.seed(0)
""".strip()

jupyterlite_silence = False

# mermaid config
mermaid_version = "11.6.0"

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]

# The master toctree document.
master_doc = "index"
# The starting document.
root_doc = "index"

remove_from_toctrees = ["generated/*"]
# The language for content autogenerated by Sphinx.
Expand Down
25 changes: 25 additions & 0 deletions doc/create_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

import pathlib


def main():
root = pathlib.Path(__file__).parent

local_channel = root.parent / "local_channel"
package_paths = list(local_channel.joinpath("noarch").glob("xarray*.conda"))
if len(package_paths) != 1:
raise RuntimeError(f"zero or more than one package found: {package_paths}")

package_path = package_paths[0]

template_path = root / "environment_template.yml"
env_path = root / "environment.yml"

template = template_path.read_text()
environment = template.replace('"{{ local-package }}"', str(package_path))

env_path.write_text(environment)

if __name__ == "__main__":
main()
29 changes: 29 additions & 0 deletions doc/environment_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: xeus-python-kernel
channels:
- https://prefix.dev/emscripten-forge-dev
- https://prefix.dev/conda-forge
dependencies:
- xeus-python
- "{{ local-package }}"

@VeckoTheGecko VeckoTheGecko Feb 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAIK Rattler already has quite good templating ability, and can even read from environment variables. Perhaps we can have a pre-build step here that just sets these environment variables before being picked up by rattler (then we don't have to work outside of Rattler's conceptual framework here)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

there's two templates right now: the version in the recipe, and the local path of the built conda package in the jupyterlite-xeus environment file. I agree, we can probably use a environment variable to set the version in the rattler recipe, but the environment file may need to have the external templating step? Unless you're proposing to use a rattler build step for that, as well?

@VeckoTheGecko VeckoTheGecko Feb 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, didn't realise that this was an environment.yml and not a rattler recipe. Then we need the templating anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we can probably remove the templating step for the recipe (which would be nice, the additional step just makes this a bit trickier), but I will defer that to a separate PR

- numpy
- pandas
- packaging
- boto3
- cartopy
- cftime
- h5netcdf
- h5py
- hdf5
- lxml # Optional dep of pydap
- matplotlib
- nc-time-axis
- netcdf4
- pint>=0.22
- pooch
- pydap
- rasterio
- scipy
- seaborn
- setuptools
- toolz
- zarr
3 changes: 3 additions & 0 deletions doc/try_examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"global_min_height": "400px"
}
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Bug Fixes

Documentation
~~~~~~~~~~~~~
- Use ``jupyterlite-sphinx`` to provide interactive examples (:pull:`10299`).
By `Justus Magin <https://github.com/keewis>`_.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this will need to be moved to the most recent release section



Internal Changes
Expand Down
50 changes: 47 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,27 @@ sphinx-copybutton = "*"
sphinx-design = "*"
sphinx-inline-tabs = "*"
sphinx-llm = ">=0.2.1"
sphinx = ">=6,<8"
sphinx = ">=8,<9"
sphinxcontrib-mermaid = "*"
sphinxcontrib-srclinks = "*"
sphinx-remove-toctrees = "*"
sphinxext-opengraph = "*"
sphinxext-rediraffe = "*"
cfgrib = "*"
myst-parser = "*"
jupyterlite-sphinx = ">=0.22.1"
jupyterlite-xeus = ">=4.4.1"

[feature.doc.tasks]
doc = { cmd = "make html", cwd = "doc", description = "Build the HTML documentation." }
doc-clean = { cmd = "make clean && make html", cwd = "doc", description = "Clean build artifacts and rebuild the HTML documentation from scratch." }
_prepare-environment = { cmd = "python create_environment.py", cwd = "doc" }
doc = { cmd = "make html", cwd = "doc", description = "Build the HTML documentation.", depends-on = [
"_prepare-environment",
] }
doc-clean = { cmd = "make clean && make html", cwd = "doc", description = "Clean build artifacts and rebuild the HTML documentation from scratch.", depends-on = [
"build",
"_prepare-environment",
] }
host-static-doc = { cmd = "python -m http.server -b 127.0.0.1 -d _build/html 5455", cwd = "doc", description = "serve the static documentation" }
linkcheck = { cmd = "make linkcheck", cwd = "doc", description = "Check URLs in documentation." }


Expand Down Expand Up @@ -341,6 +350,37 @@ rst-to-myst = { version = "*", extras = ["sphinx"] }
[feature.tools.tasks]
rst2myst = { cmd = "rst2myst", description = "Convert rst to myst markdown" }

[feature.build-package.dependencies]
gitpython = "*"
cytoolz = "*"
packaging = "*"
rattler-build = "*"

[feature.build-package.tasks.prepare-recipe]
cmd = "python ci/recipe/prepare_recipe.py"
cwd = "."

[feature.build-package.tasks.build]
cmd = [
"rattler-build",
"build",
"-c",
"conda-forge",
"--recipe",
"ci/recipe/recipe.yaml",
"--output-dir",
"local_channel",
]
Comment on lines +393 to +402

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we can probably replace this with a call to pixi publish --target-dir .

cwd = "."
depends-on = ["prepare-recipe"]

[tasks]
build-and-host-doc = [
{ task = "build" },
{ task = "doc" },
{ task = "host-static-doc" },
]

[environments]
# Testing
# test-just-xarray = { features = ["test"] } # https://github.com/pydata/xarray/pull/10888/files#r2511336147
Expand Down Expand Up @@ -454,3 +494,7 @@ default = { features = [
] }
policy = { features = ["policy"], no-default-feature = true }
tools = { features = ["tools"], no-default-feature = true }
build-package = { features = [
"build-package",
"release",
], no-default-feature = true }