Skip to content

Commit b2cf71f

Browse files
committed
Starting migration to mdBook.
1 parent fc4484b commit b2cf71f

File tree

4 files changed

+190
-6
lines changed

4 files changed

+190
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy mdBook to GitHub Pages
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["main"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Rust
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
toolchain: stable
35+
override: true
36+
37+
- name: Install mdBook
38+
run: cargo install mdbook
39+
40+
- name: Setup Pages
41+
id: pages
42+
uses: actions/configure-pages@v3
43+
44+
- name: Build with mdBook
45+
run: |
46+
cd better-code
47+
mdbook build
48+
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v2
51+
with:
52+
path: ./better-code/book
53+
54+
# Deployment job
55+
deploy:
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
runs-on: ubuntu-latest
60+
needs: build
61+
steps:
62+
- name: Deploy to GitHub Pages
63+
id: deployment
64+
uses: actions/deploy-pages@v2

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
1-
## Welcome to Better Code
1+
# Welcome to Better Code
22

33
This is the development home of the STLab Better Code course.
44

5-
Please see the [latest published draft](https://stlab.github.io/better-code/)
6-
for information about the motivation for this project.
5+
## Working with the Book
76

8-
### Infrastructure
7+
We're migrating from using Jekyll to using
8+
[mdBook](https://github.com/rust-lang/mdBook). The mdBook version is located in
9+
the `./better-code` directory and includes automated CI/CD deployment to GitHub Pages.
10+
11+
## Installing and updating mdBook
12+
13+
Install [Rust and
14+
Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html):
15+
16+
Linux and macOS:
17+
18+
```
19+
curl https://sh.rustup.rs -sSf | sh
20+
```
21+
22+
On Windows, you can download the installer from
23+
[here](https://win.rustup.rs/).
24+
25+
Once you have Rust and Cargo installed, you can install or upgrade mdBook by running:
26+
27+
```
28+
cargo install mdbook
29+
```
930

10-
The reference is developed as a [Jekyll](https://jekyllrb.com) website,
11-
currently being served by [GitHub Pages](https://pages.github.com).
31+
## Building the book
32+
33+
To build the book, run:
34+
35+
```
36+
mdbook serve ./better-code
37+
```
38+
39+
Open the browser to http://localhost:3000 to see the book. You can use the
40+
Simple Browser in VSCode/Cursor to view the book while editing.
41+
42+
## Automated Deployment
43+
44+
The mdBook is automatically built and deployed to GitHub Pages using GitHub Actions.
45+
When you push changes to the main branch:
46+
47+
1. GitHub Actions will build the book using mdBook
48+
2. The built book will be deployed to GitHub Pages
49+
3. The book will be available at https://stlab.github.io/better-code/
50+
51+
No manual deployment steps are required!
1252

1353
### Conventions and Guidelines
1454

@@ -23,6 +63,18 @@ currently being served by [GitHub Pages](https://pages.github.com).
2363
* Maintain stable file names and heading titles for linkability until another
2464
solution is in place.
2565

66+
### Older draft
67+
68+
Please see the [latest published draft](https://stlab.github.io/better-code/)
69+
for information about the motivation for this project.
70+
71+
### Infrastructure
72+
73+
The book is being migrated from [Jekyll](https://jekyllrb.com) to [mdBook](https://github.com/rust-lang/mdBook).
74+
The new mdBook version is automatically built and deployed to [GitHub Pages](https://pages.github.com) using GitHub Actions.
75+
76+
The legacy Jekyll files remain in the root directory for reference during the transition.
77+
2678
### Running a local server
2779

2880
If you are able to install the necessary parts for jekyll,

better-code/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Better Code - mdBook
2+
3+
This directory contains the mdBook version of the Better Code course.
4+
5+
## Local Development
6+
7+
### Prerequisites
8+
9+
Install [Rust and Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html):
10+
11+
**Linux and macOS:**
12+
```bash
13+
curl https://sh.rustup.rs -sSf | sh
14+
```
15+
16+
**Windows:**
17+
Download the installer from [here](https://win.rustup.rs/).
18+
19+
### Install mdBook
20+
21+
```bash
22+
cargo install mdbook
23+
```
24+
25+
### Building and Serving the Book
26+
27+
To build and serve the book locally:
28+
29+
```bash
30+
mdbook serve
31+
```
32+
33+
This will start a local server at `http://localhost:3000`.
34+
35+
To just build the book without serving:
36+
37+
```bash
38+
mdbook build
39+
```
40+
41+
The built book will be in the `book/` directory.
42+
43+
## Deployment
44+
45+
The book is automatically built and deployed to GitHub Pages using GitHub Actions when changes are pushed to the main branch.
46+
47+
## Adding Content
48+
49+
1. Edit existing chapters in the `src/` directory
50+
2. Add new chapters by creating new `.md` files in `src/`
51+
3. Update `src/SUMMARY.md` to include new chapters in the table of contents
52+
4. The book will automatically rebuild when you push changes to GitHub

better-code/book.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,19 @@ language = "en"
44
multilingual = false
55
src = "src"
66
title = "Better Code"
7+
description = "A principled and rigorous approach to software development"
8+
9+
[build]
10+
build-dir = "book"
11+
12+
[output.html]
13+
git-repository-url = "https://github.com/stlab/better-code"
14+
edit-url-template = "https://github.com/stlab/better-code/edit/main/better-code/src/{path}"
15+
site-url = "/better-code/"
16+
cname = "stlab.github.io"
17+
18+
[output.html.search]
19+
enable = true
20+
21+
[output.html.print]
22+
enable = true

0 commit comments

Comments
 (0)