Skip to content

Commit d4325e7

Browse files
committed
Refactor the build system
1 parent 83728db commit d4325e7

35 files changed

+114
-125
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
\#*
22
.#*
33
_requirements.installed
4-
build
54
*.DS_Store
65
*.html
76
*.ipynb_checkpoints
87
*.pyc
98
*~
10-
*pano-advanced-output.png
11-
book/lessons
129

13-
# ignoring website local builds
14-
site/_build
10+
# Ignore built website
11+
book/_build
12+
13+
# Ignore auto-generated content
14+
book/_modules

Makefile

+16-30
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
1-
.PHONY: html
1+
.PHONY: clean book
22

3-
OBSHELL=/bin/bash
3+
.DEFAULT_GOAL = book
44

5-
.DEFAULT_GOAL = html
5+
NB_DIR = modules
6+
EXEC_NB_DIR = book/_modules
67

7-
LESSONS_DIR = lessons
8-
GENERATED_LESSONS_DIR = site/lessons
8+
MARKDOWNS = $(wildcard $(NB_DIR)/*.md)
9+
NOTEBOOKS = $(patsubst $(NB_DIR)/%.md, $(EXEC_NB_DIR)/%.ipynb, $(MARKDOWNS))
910

1011
_requirements.installed:
1112
pip install -q -r requirements.txt
1213
touch _requirements.installed
1314

14-
MARKDOWNS = $(wildcard $(LESSONS_DIR)/*.md)
15-
MD_OUTPUTS = $(patsubst $(LESSONS_DIR)/%.md, $(GENERATED_LESSONS_DIR)/%.md, $(MARKDOWNS))
16-
NOTEBOOKS = $(patsubst %.md, %.ipynb, $(MD_OUTPUTS))
15+
$(EXEC_NB_DIR):
16+
mkdir book/_modules
1717

18-
.SECONDARY: $(MD_OUTPUTS) $(NOTEBOOKS)
18+
$(EXEC_NB_DIR)/%.ipynb:$(NB_DIR)/%.md $(EXEC_NB_DIR)
19+
@# Jupytext will also catch and print execution errors
20+
@# unless a cell is marked with the `raises-exception` tag
21+
jupytext --execute --to ipynb --output $@ $<
1922

20-
$(GENERATED_LESSONS_DIR)/%.ipynb:$(LESSONS_DIR)/%.md site/lessons site/lessons/images
21-
# This does not work, due to bug in notedown; see https://github.com/aaren/notedown/issues/53
22-
#notedown --match=python --precode='%matplotlib inline' $< > $@
23-
notedown --match=python $< > $@
24-
jupyter nbconvert --execute --inplace $@ --ExecutePreprocessor.timeout=-1
25-
26-
%.md:%.ipynb
27-
jupyter nbconvert --to=mdoutput --output="$(notdir $@)" --output-dir=$(GENERATED_LESSONS_DIR) $<
28-
# $(eval NBSTRING := [📂 Download lesson notebook](.\/$(basename $(notdir $@)).ipynb)\n\n)
29-
# sed -i'.bak' '1s/^/$(NBSTRING)/' $@
30-
31-
site/lessons:
32-
mkdir -p book/lessons
33-
34-
site/lessons/images:
35-
ln -s ${PWD}/lessons/images ${PWD}/site/lessons/images
36-
37-
html: site/lessons _requirements.installed $(NOTEBOOKS) $(MD_OUTPUTS)
38-
@export SPHINXOPTS=-W; make -C site html
39-
cp $(GENERATED_LESSONS_DIR)/*.ipynb book/build/html/lessons/
23+
book: _requirements.installed $(NOTEBOOKS)
24+
@export SPHINXOPTS=-W; make -C book html
4025

4126
clean:
42-
rm -rf $(GENERATED_LESSONS_DIR)/*
27+
make -C book clean
28+

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
scikit-image tutorials
2-
======================
1+
# scikit-image tutorials
32

43
A collection of tutorials for the [scikit-image](http://skimage.org) package.
54

@@ -16,8 +15,7 @@ Refer to [the gallery](http://scikit-image.org/docs/dev/auto_examples/) as
1615
well as [scikit-image demos](https://github.com/scikit-image/skimage-demos)
1716
for more examples.
1817

19-
Usage
20-
-----
18+
## Usage
2119

2220
These usage guidelines are based on goodwill. They are not a legal contract.
2321

@@ -42,9 +40,28 @@ For more information on these guidelines, which are sometimes known as
4240
CC0 (+BY), see [this blog post](http://www.dancohen.org/2013/11/26/cc0-by/) by
4341
Dan Cohen.
4442

45-
Contributing
46-
------------
43+
## Contributing
4744

4845
If you make any modifications to these tutorials that you think would benefit
4946
the community at large, please
5047
[create a pull request](http://scikit-image.org/docs/dev/contribute.html)!
48+
49+
The tutorials live at
50+
https://github.com/scikit-image/skimage-tutorials
51+
52+
53+
## Contributor notes
54+
55+
- Notebooks are stored in `modules`; see [modules/00_images_are_arrays.md](modules/00_images_are_arrays.md)
56+
for an example.
57+
- They use the [myst](https://myst-nb.readthedocs.io/en/latest/)
58+
notebook format
59+
- Cells can be tagged with:
60+
`remove-input` : Get rid of the input but display the output
61+
`remove-output` : Show the input but not the output
62+
`raises-exception` : This cell is expected to fail execution, so
63+
don't halt the book build because of it.
64+
65+
To build the book, run `make`. Results appear in `book/_build`.
66+
Notebooks can be edited in your favorite text editor or in Jupyter (as
67+
long as Jupytext is installed).

_config.yml

-10
This file was deleted.
+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
1+
.PHONY: help Makefile clean
32

43
# You can set these variables from the command line, and also
54
# from the environment for the first two.
@@ -12,18 +11,10 @@ BUILDDIR = _build
1211
help:
1312
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1413

15-
notebooks:
16-
mkdir -p notebooks
17-
jupytext -k python3 ../content/*.md --from myst --to notebook
18-
mv ../content/*.ipynb notebooks
19-
2014
clean:
2115
rm -rf _build
22-
rm -rf notebooks
23-
24-
.PHONY: help Makefile notebooks clean
2516

2617
# Catch-all target: route all unknown targets to Sphinx using the new
2718
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2819
%: Makefile
29-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
File renamed without changes.
File renamed without changes.

book/applications.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# scikit-image applications
2+
3+
A collection of tutorials highlighting the use of scikit-image for applications in science.
4+
5+
```{toctree}
6+
---
7+
maxdepth: 1
8+
---
9+
_modules/adv0_chromosomes.md
10+
_modules/adv1_lesion-quantification.md
11+
_modules/adv2_microarray.md
12+
_modules/adv3_panorama_stitching.md
13+
_modules/adv4_warping.md
14+
_modules/adv5_pores.md
15+
```

site/conf.py renamed to book/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'myst_nb',
3232
'sphinx_copybutton',
3333
]
34+
jupyter_execute_notebooks = "off"
3435

3536
# Add any paths that contain templates here, relative to this directory.
3637
templates_path = ['_templates']
@@ -67,4 +68,4 @@
6768
# Add any paths that contain custom static files (such as style sheets) here,
6869
# relative to this directory. They are copied after the builtin static files,
6970
# so a file named "default.css" will overwrite the builtin "default.css".
70-
html_static_path = ['_static']
71+
html_static_path = ['_static']

site/images renamed to book/images

File renamed without changes.

site/index.md renamed to book/index.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[launch_binder]: http://mybinder.org/v2/gh/scikit-image/skimage-tutorials/main?urlpath=lab/tree/content
66

7-
## Content
7+
## Content
88

99
```{toctree}
1010
---
@@ -14,9 +14,8 @@ introduction
1414
applications
1515
```
1616

17-
1817
## Indices and tables
1918

2019
* {ref}`genindex`
2120
* {ref}`modindex`
22-
* {ref}`search`
21+
* {ref}`search`

site/introduction.md renamed to book/introduction.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Basic tutorials to prepare you for your journey on scikit-image.
66
---
77
maxdepth: 1
88
---
9-
content/tour_of_skimage.md
10-
content/00_images_are_arrays.md
11-
```
9+
_modules/tour_of_skimage
10+
_modules/00_images_are_arrays
11+
```

0 commit comments

Comments
 (0)