Skip to content

Commit 2ccba21

Browse files
committed
migrate to mdbook
1 parent bc9e8bc commit 2ccba21

69 files changed

Lines changed: 3705 additions & 2208 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yaml‎

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,29 @@ jobs:
1111
with:
1212
path: "tutorial"
1313

14-
- name: Checkout generator
15-
uses: actions/checkout@v2
16-
with:
17-
repository: "viperproject/viperonline-tutorial-generator"
18-
token: ${{ secrets.GH_PAT }}
19-
path: "generator"
20-
2114
- name: Checkout build branch
2215
uses: actions/checkout@v2
2316
with:
2417
ref: "build"
25-
path: "generator/build"
26-
27-
- name: Create directory structure
28-
run: |
29-
cd generator
30-
rm -rf build/css build/images build/js
31-
cp -r assets/css build/css
32-
cp -r assets/images build/images
33-
cp -r assets/js build/js
18+
path: "tutorial/book"
3419

35-
- name: Install node packages
36-
run: |
37-
cd generator
38-
npm install
20+
- name: Setup mdBook
21+
uses: peaceiris/actions-mdbook@v1
22+
with:
23+
mdbook-version: "latest"
3924

4025
- name: Generate tutorial
4126
run: |
42-
cd generator
43-
node index.js \
44-
../tutorial/tutorial/introduction.md \
45-
../tutorial/tutorial/structure.md \
46-
../tutorial/tutorial/permissions.md \
47-
../tutorial/tutorial/predicates.md \
48-
../tutorial/tutorial/functions.md \
49-
../tutorial/tutorial/quantifiers.md \
50-
../tutorial/tutorial/quantified-permissions.md \
51-
../tutorial/tutorial/magic-wands.md \
52-
../tutorial/tutorial/statements.md \
53-
../tutorial/tutorial/expressions-and-assertions.md \
54-
../tutorial/tutorial/domains.md \
55-
../tutorial/tutorial/termination.md \
56-
../tutorial/tutorial/further-info.md
27+
cd tutorial
28+
mdbook build
5729
5830
- name: Create build commit
31+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
5932
run: |
60-
cd generator/build
33+
cd tutorial/book
6134
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
6235
git config --local user.name "github-actions[bot]"
63-
git add css images js index.html
36+
git add css FontAwesome fonts *.html *.js *.css
6437
git commit -m "Deploy $(date +'%Y-%m-%d %H:%M:%S')"
6538
6639
- name: Push tutorial to build branch
@@ -69,4 +42,4 @@ jobs:
6942
with:
7043
branch: build
7144
force: true
72-
directory: generator/build
45+
directory: tutorial/book

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tutorial/tutorial.md
1+
book

‎README.md‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,40 @@ Feel free to submit your fixes and additions via pull requests.
66

77
Please report technical issues via the issue tracker.
88

9-
# Editing
9+
## Building
1010

11-
## Interactive Viper code snippets
11+
The tutorial uses [`mdbook`](https://rust-lang.github.io/mdBook/) to generate HTML pages. To build, run (from the repository root):
1212

13-
In order to create an interacative code snippet (which can be verified directly in the web browser), inser the code in the following way:
13+
```bash
14+
mdbook build
15+
```
16+
17+
This creates a folder called `book`. To watch for changes and automatically rebuild files when the source content updates:
18+
19+
```bash
20+
mdbook serve
21+
```
22+
23+
## Editing
1424

25+
### Interactive Viper code snippets
1526

16-
````Markdown
27+
In order to create an interacative code snippet (which can be verified directly in the web browser), insert the code in the following way:
1728

18-
```silver {.runnable }
29+
````md
30+
```viper,editable,playground
1931
method foobar()
2032
{
2133
assert false
2234
}
2335
```
2436
````
2537

26-
## Including exercises
38+
### Including exercises
2739

2840
Use the following syntax in order to include an exercise to the tutorial:
2941

30-
```Markdown
31-
32-
//exercise//
33-
34-
* Sub-task A
35-
* Sub-task B
36-
* Sub-task C
37-
38-
///
39-
```
42+
```md
43+
> **Exercise**
44+
> * ...
45+
```

‎book.toml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[book]
2+
authors = ["ETH Zurich"]
3+
language = "en"
4+
src = "src"
5+
title = "Viper Tutorial"
6+
7+
[output.html.playpen]
8+
editable = true
9+
10+
[output.html]
11+
additional-js = [
12+
"editor.js",
13+
"mode-viper.js",
14+
]
15+
# additional-js = ["highlight.viper.js"]

‎editor.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
window.editors = [];
3+
(function(editors) {
4+
if (typeof(ace) === 'undefined' || !ace) {
5+
return;
6+
}
7+
8+
Array.from(document.querySelectorAll('.editable')).forEach(function(editable) {
9+
let display_line_numbers = window.playground_line_numbers || false;
10+
11+
let editor = ace.edit(editable);
12+
editor.setOptions({
13+
highlightActiveLine: false,
14+
showPrintMargin: false,
15+
showLineNumbers: display_line_numbers,
16+
showGutter: true, // display_line_numbers,
17+
maxLines: Infinity,
18+
fontSize: "0.875em", // please adjust the font size of the code in general.css
19+
useSoftTabs: true,
20+
tabSize: 2,
21+
});
22+
23+
editor.$blockScrolling = Infinity;
24+
25+
editor.getSession().setMode("ace/mode/viper");
26+
27+
editor.originalCode = editor.getValue();
28+
29+
editors.push(editor);
30+
});
31+
})(window.editors);

0 commit comments

Comments
 (0)