Skip to content

Commit cb2d9d1

Browse files
authored
Merge pull request #50 from rossbar/myst
2 parents b63547f + a4de58d commit cb2d9d1

File tree

6 files changed

+175
-1
lines changed

6 files changed

+175
-1
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,19 @@ jobs:
112112

113113
- name: Build jupyterlite site
114114
run: pixi run build_wasm
115+
116+
myst_build:
117+
name: Build and execute static site with myst
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v4
121+
- name: Setup environment
122+
run: pip install -r requirements.txt
123+
- name: Build site with execution
124+
run: |
125+
myst build --execute 2>&1 |tee /tmp/mystbuild.log
126+
if grep -q "Traceback .most recent call last." /tmp/mystbuild.log; then
127+
exit 1;
128+
else
129+
exit 0;
130+
fi

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,40 @@ covering some core features:
4949
pip install -r requirements.txt
5050
jupyter lab
5151
```
52+
## Build the site
53+
54+
There are currently two distinct technology stacks that support the
55+
`executable-tutorials` paradigm: a legacy sphinx-based static-site generation
56+
engine, and the newer [myst][myst-org] project.
57+
The `executable-tutorials` repo contains information about both development
58+
patterns, and endeavors to serve as a transition guide between technology
59+
stacks.
60+
61+
By default, the necessary tooling for both technology stacks is installed with
62+
`pip install -r requirements.txt`
63+
64+
### Build with sphinx
65+
66+
```bash
67+
make html
68+
```
69+
70+
The static site can then be viewed by simply opening the index in any browser,
71+
for example::
72+
73+
```bash
74+
firefox _build/html/index.html
75+
```
76+
77+
### Build with `myst`
78+
79+
```bash
80+
myst start --execute
81+
```
82+
83+
This will execute the notebooks, build the site, and set up a server for rendering
84+
the site.
85+
The rendered page can be viewed by opening `localhost:3000` in a browser.
5286

5387
## Make Your Own
5488

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
nb_merge_streams = True
3939
nb_execution_mode = "cache"
4040

41-
nb_execution_excludepatterns = []
41+
# We do ignore the JB2 landing page when rendering with JB1
42+
exclude_patterns += ['index_jb2.md']
4243

4344

4445
# -- Options for HTML output -------------------------------------------------

index_jb2.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Executable Tutorials
2+
3+
This is meant to demonstrate by example how to deploy tutorial materials. The
4+
examples show common patterns including runnable code, plots, exercises with
5+
solutions, etc.
6+
7+
## How to Run The Code
8+
9+
`````{tab-set}
10+
````{tab-item} Locally with pixi
11+
12+
Clone the repository and launch JupyterLab.
13+
14+
```sh
15+
git clone https://github.com/scientific-python/executable-tutorials
16+
cd executable-tutorials
17+
18+
pixi run start
19+
```
20+
````
21+
22+
````{tab-item} Locally with pip
23+
24+
Clone the repository, create an enviornment, install the requirements, and
25+
launch JupyterLab.
26+
27+
28+
```sh
29+
git clone https://github.com/scientific-python/executable-tutorials
30+
cd executable-tutorials
31+
32+
python -m venv .venv
33+
source .venv/bin/activate
34+
35+
pip install -r requirements.txt
36+
jupyter lab
37+
```
38+
````
39+
40+
````{tab-item} In Cloud with Binder
41+
42+
[Open on Binder][].
43+
44+
````
45+
46+
````{tab-item} JupyterLite (experimental)
47+
48+
[Open with JupyterLite][].
49+
50+
````
51+
`````
52+
53+
Or, instead of _running_ the code, you may view the code and results by
54+
following the links below.
55+
56+
## Example Tutorials
57+
58+
We maintain a collection of example tutorials so showcase some features.
59+
60+
::::{grid} 1 1 2 2
61+
:::{card} Executable Code ✨
62+
:link: ./tutorials/executable/basics.md
63+
Tutorial with basic executable cells.
64+
:::
65+
66+
:::{card} Interactive Matplotlib Figures 🐍
67+
:link: ./tutorials/matplotlib/interactive_mpl.md
68+
Tutorial with interactive matplotlib figures.
69+
:::
70+
71+
:::{card} Static Matplotlib Figures 📑
72+
:link: ./tutorials/matplotlib/static_mpl.md
73+
Tutorial with interactive matplotlib figures.
74+
:::
75+
76+
:::{card} Static Code 📖
77+
:link: ./tutorials/static/static.md
78+
Tutorial with static content, code cells are not executed.
79+
:::
80+
81+
::::
82+
83+
84+
## Contributing documentation
85+
86+
We maintain guideline documents for maintainers of tutorial repositories in our [Maintainers' Guide](./maintainer-guide.md).
87+
We envision this document to be a collection of collective wisdom about maintaining MyST Markdown based executable tutorials.
88+
89+
We also have a document for contributors of this repository in our [Contributors' Guide](./contributing.md).
90+
91+
92+
[Open on Binder]: https://mybinder.org/v2/gh/scientific-python/executable-tutorials/main?urlpath=tree/tutorials/
93+
[Open with JupyterLite]: https://scientific-python.github.io/executable-tutorials/jupyterlite/lab/index.html

myst.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See docs at: https://mystmd.org/guide/frontmatter
2+
version: 1
3+
project:
4+
id: 9db2473e-461d-4266-86fa-a2a0ea3eb2c9
5+
title: Executable Tutorials
6+
description: Executable tutorials for Scientific Python
7+
keywords: []
8+
authors: [Scientific Python Developers]
9+
github: https://github.com/scientific-python/executable-tutorials
10+
# To autogenerate a Table of Contents, run "myst init --write-toc"
11+
toc:
12+
# Auto-generated by `myst init --write-toc`
13+
- file: index_jb2.md
14+
- title: Tutorials
15+
children:
16+
- file: tutorials/executable/basics.md
17+
- file: tutorials/matplotlib/interactive_mpl.md
18+
- file: tutorials/matplotlib/static_mpl.md
19+
- file: tutorials/static/static.md
20+
- file: contributing.md
21+
- file: maintainer-guide.md
22+
23+
site:
24+
template: book-theme
25+
# options:
26+
# favicon: favicon.ico
27+
# logo: site_logo.png

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ nbval
1313
pytest-custom_exit_code
1414
jupytext
1515
jupyterlab-myst
16+
# For myst stack
17+
mystmd
18+
jupyter

0 commit comments

Comments
 (0)