Skip to content

Commit a731ac4

Browse files
committed
Update build system and CI
- building examples now places them in docs/exercises and docs/solutions rather than build/ - mkdocs is responsible for compiling from docs/ to build/ and depends on the examples already being in place (reflected in the Makefile) - CI now tests building the tutorial in PRs - CI has been updated to publish the new docs to GitHub Pages
1 parent e11572b commit a731ac4

File tree

6 files changed

+106
-46
lines changed

6 files changed

+106
-46
lines changed

.github/workflows/deploy-to-web.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,20 @@ jobs:
2222
- name: Checkout repository
2323
uses: actions/checkout@v3
2424

25-
- name: Set up Ruby
26-
uses: ruby/setup-ruby@v1
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
2727
with:
28-
ruby-version: '2.7'
28+
python-version: 3.x
2929

30-
- name: Install AsciiDoctor
31-
run: gem install asciidoctor pygments.rb
30+
- name: Install Material for MkDocs
31+
run: pip install mkdocs-material
3232

3333
- name: Clean the build directory
34-
run: rm -rf build/*
34+
run: make clean
3535

3636
- name: Build the tutorial
3737
run: make
3838

39-
- name: Move the tutorial file
40-
run: mv build/tutorial.html build/index.html
41-
4239
- name: Setup Pages
4340
uses: actions/configure-pages@v5
4441

@@ -49,4 +46,4 @@ jobs:
4946

5047
- name: Deploy to GitHub Pages
5148
id: deployment
52-
uses: actions/deploy-pages@v4
49+
uses: actions/deploy-pages@v4
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test tutorial build
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, edited]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
23+
- name: Install Material for MkDocs
24+
run: pip install mkdocs-material
25+
26+
- name: Clean the build directory
27+
run: make clean
28+
29+
- name: Check that the tutorial builds
30+
run: make

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ build/*
22
/.vscode/
33
check
44
**.swp
5+
docs/exercises
6+
docs/solutions

Makefile

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22

33
MAKEFILE_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
44

5-
default: build exercises build/tutorial.html build/exercises.zip
5+
default: tutorial
66
all: default
77

88
clean:
9-
rm -rf build TAGS
10-
11-
build:
12-
mkdir -p build
13-
mkdir -p build/exercises
14-
mkdir -p build/solutions
9+
rm -rf docs/exercises docs/solutions docs/exercises.zip build TAGS
1510

1611
##############################################################################
1712
# Exercises
1813

1914
SRC_EXAMPLES=$(shell find src/examples -type f)
20-
SOLUTIONS=$(patsubst src/examples/%, build/solutions/%, $(SRC_EXAMPLES))
21-
EXERCISES=$(patsubst src/examples/%, build/exercises/%, $(SRC_EXAMPLES))
15+
SOLUTIONS=$(patsubst src/examples/%, docs/solutions/%, $(SRC_EXAMPLES))
16+
EXERCISES=$(patsubst src/examples/%, docs/exercises/%, $(SRC_EXAMPLES))
2217

2318
CN=cn verify
2419

25-
exercises: $(EXERCISES) $(SOLUTIONS)
20+
exercises: docs-exercises-dirs $(EXERCISES) $(SOLUTIONS)
21+
22+
docs-exercises-dirs:
23+
mkdir -p docs/exercises
24+
mkdir -p docs/solutions
2625

27-
build/exercises/%: src/examples/%
26+
docs/exercises/%: src/examples/%
2827
@echo Rebuild $@
2928
@-mkdir -p $(dir $@)
3029
@sed -E '\|^.*--BEGIN--.*$$|,\|^.*--END--.*$$|d' $< > $@
3130

32-
build/solutions/%: src/examples/%
31+
docs/solutions/%: src/examples/%
3332
@-mkdir -p $(dir $@)
3433
@if [ `which cn` ]; then \
3534
if [[ "$<" = *".c"* ]]; then \
@@ -41,16 +40,15 @@ build/solutions/%: src/examples/%
4140
@echo Rebuild $@
4241
@cat $< | sed '\|^.*--BEGIN--.*$$|d' | sed '\|^.*--END--.*$$|d' > $@
4342

44-
build/exercises.zip: $(EXERCISES)
45-
cd build; zip -r exercises.zip exercises > /dev/null
43+
docs/exercises.zip: $(EXERCISES)
44+
cd docs; zip -r exercises.zip exercises > /dev/null
4645

4746
WORKING=$(wildcard src/examples/list_*.c)
48-
WORKING_AUX=$(patsubst src/examples/%, build/solutions/%, $(WORKING))
49-
temp: $(WORKING_AUX) build
50-
# build/tutorial.html
47+
WORKING_AUX=$(patsubst src/examples/%, docs/solutions/%, $(WORKING))
48+
temp: $(WORKING_AUX) docs-exercises-dirs
5149

5250
##############################################################################
53-
# Check that the examples all run correctly
51+
# Check that the examples all run correctly
5452

5553
CN_PATH?=cn verify
5654

@@ -62,23 +60,16 @@ check-tutorial:
6260
@echo Check tutorial examples
6361
@$(MAKEFILE_DIR)/check.sh "$(CN_PATH)"
6462

65-
check: check-tutorial check-archive
63+
check: check-tutorial check-archive
6664

6765
##############################################################################
6866
# Tutorial document
6967

70-
build/tutorial.adoc build/style.css build/asciidoctor.css: src/tutorial.adoc
71-
@echo Create build/tutorial.adoc
72-
@sed -E 's/include_example\((.+)\)/.link:\1[\1]\n[source,c]\n----\ninclude::\1\[\]\n----/g' $< > $@
73-
@cp src/style.css build
74-
@cp src/asciidoctor.css build
75-
76-
build/images: src/images
77-
cp -r $< $@
68+
tutorial: exercises mkdocs.yml $(shell find docs -type f)
69+
mkdocs build --strict
7870

79-
build/tutorial.html: build/tutorial.adoc $(SRC_EXAMPLES) build/images
80-
asciidoctor --doctype book $< -o $@
81-
@rm build/tutorial.adoc
71+
serve: exercises mkdocs.yml $(shell find docs -type f)
72+
mkdocs serve
8273

8374
##############################################################################
8475
# Misc

README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,55 @@ View the tutorial here: https://rems-project.github.io/cn-tutorial/
44

55
## Building
66

7+
The CN tutorial is built using [Material for
8+
MkDocs](https://squidfunk.github.io/mkdocs-material/).
9+
10+
Dependencies:
11+
* python 3.x
12+
* pip
13+
14+
```bash
15+
# Install Material for MkDocs
16+
pip install mkdocs-material
17+
18+
# Build the tutorial
19+
make
20+
```
21+
22+
### Hosting locally
23+
24+
You can start a local server that automatically renders changes to the tutorial
25+
files. This is useful while editing the tutorial.
26+
27+
```bash
28+
# Run the docs locally
29+
make serve
30+
```
31+
32+
View at: http://localhost:8000/
33+
734
Install dependencies: [asciidoctor](https://asciidoctor.org/).
835

9-
Run `make` to produce `build/tutorial.html` and its dependencies: especially, `build/exercises/*.c` and `build/solutions/*c`.
36+
## Tutorial examples
37+
38+
The tutorial examples live in [src/examples](./src/examples).
39+
40+
As part of building the tutorial, the examples are lightly preprocessed to
41+
produce solutions and exercises (solutions with the CN specifications removed).
42+
43+
Run `make exercises` to produce the exercises and solutions in the `docs`
44+
directory.
45+
46+
### Testing the tutorial examples
1047

11-
Run `make check-tutorial` to check that all examples in the tutorial have working solutions (except tests with names `*.broken.c`, which are expected to fail). Note that this step will not work until after you have installed CN, which is the first part of the tutorial.
48+
Follow these steps `make check-tutorial` to check that all examples in the tutorial have working solutions (except tests with names `*.broken.c`, which are expected to fail).
1249

13-
Run `make check` to checks both the tutorial and archive examples (see below).
50+
1. Install CN (follow steps in [the tutorial](https://rems-project.github.io/cn-tutorial/
51+
))
52+
2. Run `make check-tutorial`
1453

15-
## CN Example Archive
54+
## CN example archive
1655

1756
The subdirectory `src/example-archive` includes many more examples of CN proofs, both working and broken. See [the README](./src/example-archive/README.md) for a description how these examples are organized.
1857

19-
Run `make check-archive` to check all examples in the example archive.
58+
Install CN and run `make check-archive` to check all examples in the example archive.

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
site_name: CN Docs
2+
site_dir: build
23
theme:
34
name: material
45
features:
@@ -75,7 +76,7 @@ markdown_extensions:
7576
- pymdownx.mark
7677
- pymdownx.smartsymbols
7778
- pymdownx.snippets:
78-
base_path: ["build"]
79+
base_path: ["docs", "build"]
7980
- pymdownx.striphtml
8081
- pymdownx.superfences:
8182
custom_fences:

0 commit comments

Comments
 (0)