From 668c9ce8256ce5faed9cb6619061ba75892123c0 Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Tue, 1 Dec 2026 11:29:33 -0500 Subject: [PATCH] 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