You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/setup.md
+94-42Lines changed: 94 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Setup instructions for MkDocs with Entangled
2
-
If you'd like to use Entangled together with MkDocs, here's an opiniated guide (if you have differing opinions, you'll know howto adapt).
2
+
If you'd like to use Entangled together with MkDocs, here's an opiniated guide.
3
3
4
4
## Python and MkDocs
5
5
Start with an empty project folder, say `my-awesome-project`.
@@ -10,18 +10,17 @@ cd my_awesome_project
10
10
git init
11
11
```
12
12
13
-
You may want to setup a virtual environment to install MkDocs into. Even if your project is not Python related, it pays to have a reproducible build environment for your documentation. I use [Poetry](https://python-poetry.org/) to manage my environments.
13
+
You may want to setup a virtual environment to install MkDocs into. Even if your project is not Python related, it pays to have a reproducible build environment for your documentation. I use [`uv`](https://docs.astral.sh/uv/) to manage my environments.
Using virtual environments will take up some disk space. With these moderate requirements however, we're still under 200 MB.
23
-
24
-
Next we initialize, configure, and run MkDocs.
22
+
Now you have created a virtual environment using UV and activated it (alas there is no `uv shell` command that I know of).
23
+
Next we initialize, configure, and run MkDocs.
25
24
26
25
```sh
27
26
mkdocs new .
@@ -38,13 +37,14 @@ plugins:
38
37
- entangled
39
38
40
39
markdown_extensions:
40
+
- attr_list
41
41
- pymdownx.superfences
42
42
43
43
theme:
44
44
name: material
45
45
```
46
46
47
-
This sets the title, repo name and a toggle for dark mode viewing. the `entangled` plugin needs `pymdownx.superfences` to be enabled.
47
+
This sets the title, repo name and a toggle for dark mode viewing. the `entangled` plugin expects the `attr_list` and `pymdownx.superfences` markdown extensions to be enabled.
48
48
Make sure to check out [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) for more documentation on configuring MkDocs with Material.
49
49
50
50
```sh
@@ -56,25 +56,21 @@ This will start a build loop and web server. That means that every time one of t
56
56
## Setup Entangled
57
57
Entangled will work without any additional configuration in `entangled.toml`. The default config monitors the entire source repository for Markdown files. Files that are extracted from the Markdown are also watched for changes. If you'd like to limit the scope of Markdown files that are monitored, you can set `watch_list` to a list of glob patterns. For MkDocs projects it makes sense to set `watch_list = [ "docs/**/*.md" ]`.
58
58
59
-
To enable building artifacts add the `build` hook, by setting `hooks = ["build"]`.
59
+
We will also demo the `repl` hook for Entangled later on.
60
60
61
61
The complete configuration then looks like this:
62
62
63
63
``` {.toml file=examples/entangled.toml}
64
64
version = "2.0"
65
65
watch_list = ["docs/**/*.md"]
66
-
hooks = ["build"]
67
-
```
68
-
69
-
Entangled runs as a pre-build action in MkDocs. So, you may want to add your generated source files in the watch list of MkDocs. Assuming your source files are in `./src`:
66
+
hooks = ["repl"]
70
67
71
-
```yaml
72
-
watch:
73
-
- docs
74
-
- src
68
+
<<repl-config>>
75
69
```
76
70
77
71
## Extras
72
+
Some extras.
73
+
78
74
### Syntax Highlighting
79
75
Add the following to the `markdown_extensions` section in `mkdocs.yml`:
80
76
@@ -88,6 +84,45 @@ markdown_extensions:
88
84
pygments_lang_class: true
89
85
```
90
86
87
+
### Evaluating a REPL session
88
+
When you write documentation or teaching material it can be nice to automatically evaluate commands in a REPL and show the results in your rendered output. Entangled ships with a command-line tool `repl-session` that evaluates a series of commands in a configured REPL. Both input and output are JSON data.
89
+
Entangled contains a hook that integrates with `repl-session`.
90
+
91
+
For each language you need to configure the REPL in `entangled.toml` in the `[hook.repl.config.<language>]` section. For example,
Each repl block must be attached to a session, which is the JSON file to which the session is written. It is the responsibility of the user to make sure, with whatever build system tool (say GNU Make or Brei), that the resulting JSON file is passed through `repl-session` to a file in the same directory with the `out.json` extension. This way, the REPL session will only be rerun when the session file changes.
104
+
105
+
Did you know that Lua supports tail-call elimination? We can define a factorial function,
A common requirement is to have support for equations. Add the following to your `mkdocs.yml`
93
128
@@ -132,11 +167,11 @@ You can enable a dark-mode toggle by adding to your `mkdocs.yml`
132
167
```yaml
133
168
theme:
134
169
name: material
135
-
palette:
170
+
palette:
136
171
# Palette toggle for light mode
137
172
- scheme: default
138
173
toggle:
139
-
icon: material/brightness-7
174
+
icon: material/brightness-7
140
175
name: Switch to dark mode
141
176
142
177
# Palette toggle for dark mode
@@ -151,60 +186,77 @@ You may want to use Github Actions to deploy the website. I use the following `.
151
186
152
187
<details><summary>Deploy Pages action</summary>
153
188
189
+
Note from two years later: Github Actions are extraordinarily fickle and require constant maintenance. Always make sure that you update to the newest versions. This version is from October 2025:
190
+
154
191
```yaml
155
-
name: Deploy Pages
192
+
name: Deploy pages
156
193
157
194
# Controls when the workflow will run
158
195
on:
159
196
# Triggers the workflow on push or pull request events but only for the "main" branch
160
197
push:
161
-
branches: ["main"]
198
+
branches: ["main"]
162
199
163
200
# Allows you to run this workflow manually from the Actions tab
164
201
workflow_dispatch:
165
202
166
-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
167
203
permissions:
168
204
contents: read
169
205
pages: write
170
206
id-token: write
171
207
208
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
209
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
210
+
concurrency:
211
+
group: "pages"
212
+
cancel-in-progress: false
213
+
214
+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
172
215
jobs:
216
+
# This workflow contains a single job called "build"
173
217
build:
174
-
environment:
175
-
name: github-pages
176
-
url: ${{ steps.deployment.outputs.page_url }}
177
218
# The type of runner that the job will run on
178
219
runs-on: ubuntu-latest
179
220
180
221
# Steps represent a sequence of tasks that will be executed as part of the job
181
222
steps:
182
223
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
183
-
- uses: actions/checkout@v3
224
+
- uses: actions/checkout@v4
225
+
226
+
- name: Install uv
227
+
uses: astral-sh/setup-uv@v6
184
228
185
-
- name: Install
186
-
run: |
187
-
pip install poetry
188
-
poetry install
229
+
- name: Install dependencies
230
+
run: uv sync
231
+
232
+
- name: Run MkDocs
233
+
run: uv run mkdocs build
234
+
235
+
- name: Configure GitHub Pages
236
+
uses: actions/configure-pages@v5
189
237
190
-
- name: Generate site
191
-
run: poetry run mkdocs build
192
-
193
238
- name: Upload artifact
194
-
uses: actions/upload-pages-artifact@v1
239
+
uses: actions/upload-pages-artifact@v4
195
240
with:
196
-
path: 'site'
241
+
path: "site"
197
242
243
+
deploy:
244
+
environment:
245
+
name: github-pages
246
+
url: ${{ steps.deployment.outputs.page_url }}
247
+
runs-on: ubuntu-latest
248
+
needs: build
249
+
steps:
198
250
- name: Deploy to GitHub Pages
199
251
id: deployment
200
-
uses: actions/deploy-pages@v2
252
+
uses: actions/deploy-pages@v4
201
253
```
202
254
203
255
</details>
204
256
205
257
## Commit
206
-
Don't forget to create a `README.md`, `LICENSE`, and later on a `CITATION.cff`. You may want to add `poetry.lock` to `.gitignore`.
207
-
You should be good to go! A fresh Entangled/MkDocs project should have the following files:
258
+
Don't forget to create a `README.md`, `LICENSE`, and later on a `CITATION.cff`.
259
+
A fresh Entangled/MkDocs project should have the following files:
208
260
209
261
```
210
262
.
@@ -225,7 +277,7 @@ Create a home for your new project and push.
0 commit comments