Skip to content

Commit 0538fe6

Browse files
committed
Adding mdbook configuration and deployment to gh-pages (#111)
1 parent 533adc8 commit 0538fe6

File tree

9 files changed

+112
-0
lines changed

9 files changed

+112
-0
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MDBOOK_VERSION=0.4.4

.github/workflows/gh-pages.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: github pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Read .env
15+
id: mdbook-version
16+
run: |
17+
. ./.env
18+
echo "::set-output name=MDBOOK_VERSION::${MDBOOK_VERSION}"
19+
20+
- name: Setup mdbook
21+
uses: peaceiris/actions-mdbook@v1
22+
with:
23+
mdbook-version: '${{ steps.mdbook-version.outputs.MDBOOK_VERSION }}'
24+
25+
- run: mdbook build
26+
27+
- name: Deploy
28+
uses: peaceiris/actions-gh-pages@v3
29+
with:
30+
github_token: ${{ secrets.GITHUB_TOKEN }}
31+
publish_dir: ./book

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated output of mdbook
2+
/book

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,20 @@ We suggest leaving a comment on the [issue tracker](https://github.com/rust-unof
7878
so that other people don't start working on the same topic.
7979

8080
Correction and elaboration PRs are very welcome.
81+
82+
## Building with mdbook
83+
84+
This book is built with [mdbook](https://rust-lang.github.io/mdBook/). You can install it by running `cargo install mdbook`.
85+
86+
If you want to build it locally you can run one of these two commands in the root directory of the repository:
87+
88+
- `mdbook build`
89+
90+
Builds static html pages as output and place them in the `/book` directory by default.
91+
92+
- `mdbook serve`
93+
94+
Serves the book at `http://localhost:3000` (port is changeable, take a look at the terminal output
95+
to be sure) and reloads the browser when a change occurs.
96+
97+

SUMMARY.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Summary
2+
3+
- [Introduction](./intro.md)
4+
- [Idioms](./idioms/README.md)
5+
- [Concatenating Strings with `format!`](./idioms/concat-format.md)
6+
- [Constructor](./idioms/ctor.md)
7+
- [The `Default` Trait](./idioms/default.md)
8+
- [Collections Are Smart Pointers](./idioms/deref.md)
9+
- [Finalisation in Destructors](./idioms/dtor-finally.md)
10+
- [`mem::replace(_)`](./idioms/mem-replace.md)
11+
- [On-Stack Dynamic Dispatch](./idioms/on-stack-dyn-dispatch.md)
12+
- [Iterating over an `Option`](./idioms/option-iter.md)
13+
- [Pass Variables to Closure](./idioms/pass-var-to-closure.md)
14+
- [Privacy For Extensibility](./idioms/priv-extend.md)
15+
- [Easy doc initialization](./idioms/rustdoc-init.md)
16+
- [Temporary mutability](./idioms/temporary-mutability.md)
17+
18+
- [Design Patterns](./patterns/README.md)
19+
- [Builder](./patterns/builder.md)
20+
- [Compose Structs](./patterns/compose-structs.md)
21+
- [Entry API](./patterns/entry.md)
22+
- [Fold](./patterns/fold.md)
23+
- [Late Bound Bounds](./patterns/late-bounds.md)
24+
- [Newtype](./patterns/newtype.md)
25+
- [RAII Guards](./patterns/RAII.md)
26+
- [Prefer Small Crates](./patterns/small-crates.md)
27+
- [Contain unsafety in small modules](./patterns/unsafe-mods.md)
28+
- [Visitor](./patterns/visitor.md)
29+
30+
- [Anti-patterns](./anti_patterns/README.md)
31+
- [`#[deny(warnings)]`](./anti_patterns/deny-warnings.md)
32+
- [Deref Polymorphism](./anti_patterns/deref.md)

anti_patterns/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Anti-patterns
2+
3+
TODO: add description/explanation

book.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[book]
2+
title = "Rust Design Patterns"
3+
authors = ["the rust-unofficial authors"]
4+
description = "A catalogue of Rust design patterns, anti-patterns and idioms"
5+
language = "en"
6+
multilingual = false
7+
src = "."
8+
9+
[build]
10+
create-missing = false
11+
12+
[rust]
13+
edition = "2018"
14+
15+
[output.html]
16+
default-theme = "rust"
17+
git-repository-url = "https://github.com/rust-unofficial/patterns"
18+
git-repository-icon = "fa-github"
19+
20+
# [output.linkcheck] # enable the "mdbook-linkcheck" renderer, disabled due to gh-actions

idioms/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Idioms
2+
3+
TODO: add description/explanation

patterns/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Design Patterns
2+
3+
TODO: add description/explanation

0 commit comments

Comments
 (0)