From 27f1258ee7f0cce545b6e71ab0e27edfabdedc9d Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Tue, 1 Dec 2026 11:29:33 -0500 Subject: [PATCH 1/2] ENH: Add Binder launch and live-code buttons to each tutorial --- _static/custom.css | 5 +++++ content/index.md | 19 +++++++++++++------ myst.yml | 5 +++++ postBuild | 5 +++++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 postBuild diff --git a/_static/custom.css b/_static/custom.css index 96db47511..ce0ad72b2 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -3,3 +3,8 @@ table-layout: fixed; width: 100%; } + +/* Show the launch (rocket) button only on pages with executable cells. */ +main:not(:has(.myst-jp-nb-toolbar)) .myst-fm-launch-button { + display: none; +} diff --git a/content/index.md b/content/index.md index 19ce61a1f..a50e3d9ef 100644 --- a/content/index.md +++ b/content/index.md @@ -12,12 +12,19 @@ teaching classes with. If you're interested in adding your own content, check the [Contributing](contributing.md) section. To open a live version of the content, click the **launch Binder** button above. -To open each of the `.md` files, right click and select "Open with -> Notebook". -You can also launch individual tutorials on Binder by clicking on the rocket -icon that appears in the upper-right corner of each tutorial. To download a -local copy of the `.ipynb` files, you can either -[clone this repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) -or use the download icon in the upper-right corner of each tutorial. +The `.md` files open as notebooks. If one opens as plain text instead, right +click it and select "Open with -> Notebook". + +Each tutorial also has its own buttons in the upper-right corner of the page: + +- the rocket icon opens that tutorial on Binder, or on a JupyterHub of your + choice, +- the power icon starts a Binder-backed kernel so that you can edit and run the + code cells without leaving the page, +- the download icon saves a local copy of the tutorial. + +You can also get all the tutorials at once by +[cloning this repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository). ## Useful links and resources diff --git a/myst.yml b/myst.yml index f88970d2a..8259c6c09 100644 --- a/myst.yml +++ b/myst.yml @@ -5,6 +5,11 @@ project: # keywords: [] authors: Numpy Community github: https://github.com/numpy/numpy-tutorials + # Adds launch (rocket) and live-code (power) buttons to each tutorial + jupyter: + binder: + repo: numpy/numpy-tutorials + ref: main toc: - file: content/index.md diff --git a/postBuild b/postBuild new file mode 100755 index 000000000..2ac790f55 --- /dev/null +++ b/postBuild @@ -0,0 +1,5 @@ +#!/bin/bash +# Binder: open the .md tutorials as notebooks, not text files. +set -euo pipefail + +jupytext-config set-default-viewer markdown myst From db5039b28e7cf5c05b3112ba96336d9c5adb8fe0 Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Wed, 2 Dec 2026 21:41:12 -0500 Subject: [PATCH 2/2] MAINT: Consolidate dependencies and isolate Binder configuration --- postBuild => .binder/postBuild | 0 .binder/requirements.txt | 2 ++ environment.yml | 18 ------------------ 3 files changed, 2 insertions(+), 18 deletions(-) rename postBuild => .binder/postBuild (100%) create mode 100644 .binder/requirements.txt delete mode 100644 environment.yml diff --git a/postBuild b/.binder/postBuild similarity index 100% rename from postBuild rename to .binder/postBuild diff --git a/.binder/requirements.txt b/.binder/requirements.txt new file mode 100644 index 000000000..3c6ece431 --- /dev/null +++ b/.binder/requirements.txt @@ -0,0 +1,2 @@ +-r ../requirements.txt +jupyterlab_myst diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 769fb7b04..000000000 --- a/environment.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: numpy-tutorials -channels: - - conda-forge -dependencies: - # For running the tutorials - - numpy - - scipy - - pooch - - matplotlib - - pandas - - imageio - # For building the site - - tox - - jupytext - - pip - - pip: - - jupyter-book>=2 - - jupyterlab_myst