From 3f3ae4ae731bb4e5e8edb7c1cc3f24da48949dcd Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Fri, 1 Jan 2021 12:27:42 +0100 Subject: [PATCH] Adding mdbook configuration and deployment to gh-pages (#111) --- .env | 1 + .github/workflows/gh-pages.yml | 31 +++++++++++++++++++++++++++++++ .gitignore | 2 ++ README.md | 17 +++++++++++++++++ SUMMARY.md | 32 ++++++++++++++++++++++++++++++++ anti_patterns/README.md | 3 +++ book.toml | 20 ++++++++++++++++++++ idioms/README.md | 3 +++ patterns/README.md | 3 +++ 9 files changed, 112 insertions(+) create mode 100644 .env create mode 100644 .github/workflows/gh-pages.yml create mode 100644 .gitignore create mode 100644 SUMMARY.md create mode 100644 anti_patterns/README.md create mode 100644 book.toml create mode 100644 idioms/README.md create mode 100644 patterns/README.md diff --git a/.env b/.env new file mode 100644 index 0000000..82f6f28 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +MDBOOK_VERSION=0.4.4 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..b0b8e2f --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,31 @@ +name: github pages + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Read .env + id: mdbook-version + run: | + . ./.env + echo "::set-output name=MDBOOK_VERSION::${MDBOOK_VERSION}" + + - name: Setup mdbook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: '${{ steps.mdbook-version.outputs.MDBOOK_VERSION }}' + + - run: mdbook build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..851a43b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Generated output of mdbook +/book diff --git a/README.md b/README.md index 8ebdca4..03093c6 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,20 @@ We suggest leaving a comment on the [issue tracker](https://github.com/rust-unof so that other people don't start working on the same topic. Correction and elaboration PRs are very welcome. + +## Building with mdbook + +This book is built with [mdbook](https://rust-lang.github.io/mdBook/). You can install it by running `cargo install mdbook`. + +If you want to build it locally you can run one of these two commands in the root directory of the repository: + +- `mdbook build` + + Builds static html pages as output and place them in the `/book` directory by default. + +- `mdbook serve` + + Serves the book at `http://localhost:3000` (port is changeable, take a look at the terminal output + to be sure) and reloads the browser when a change occurs. + + \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md new file mode 100644 index 0000000..5a56e46 --- /dev/null +++ b/SUMMARY.md @@ -0,0 +1,32 @@ +# Summary + +- [Introduction](./intro.md) +- [Idioms](./idioms/README.md) + - [Concatenating Strings with `format!`](./idioms/concat-format.md) + - [Constructor](./idioms/ctor.md) + - [The `Default` Trait](./idioms/default.md) + - [Collections Are Smart Pointers](./idioms/deref.md) + - [Finalisation in Destructors](./idioms/dtor-finally.md) + - [`mem::replace(_)`](./idioms/mem-replace.md) + - [On-Stack Dynamic Dispatch](./idioms/on-stack-dyn-dispatch.md) + - [Iterating over an `Option`](./idioms/option-iter.md) + - [Pass Variables to Closure](./idioms/pass-var-to-closure.md) + - [Privacy For Extensibility](./idioms/priv-extend.md) + - [Easy doc initialization](./idioms/rustdoc-init.md) + - [Temporary mutability](./idioms/temporary-mutability.md) + +- [Design Patterns](./patterns/README.md) + - [Builder](./patterns/builder.md) + - [Compose Structs](./patterns/compose-structs.md) + - [Entry API](./patterns/entry.md) + - [Fold](./patterns/fold.md) + - [Late Bound Bounds](./patterns/late-bounds.md) + - [Newtype](./patterns/newtype.md) + - [RAII Guards](./patterns/RAII.md) + - [Prefer Small Crates](./patterns/small-crates.md) + - [Contain unsafety in small modules](./patterns/unsafe-mods.md) + - [Visitor](./patterns/visitor.md) + +- [Anti-patterns](./anti_patterns/README.md) + - [`#[deny(warnings)]`](./anti_patterns/deny-warnings.md) + - [Deref Polymorphism](./anti_patterns/deref.md) diff --git a/anti_patterns/README.md b/anti_patterns/README.md new file mode 100644 index 0000000..c318b4d --- /dev/null +++ b/anti_patterns/README.md @@ -0,0 +1,3 @@ +# Anti-patterns + +TODO: add description/explanation diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..c43d672 --- /dev/null +++ b/book.toml @@ -0,0 +1,20 @@ +[book] +title = "Rust Design Patterns" +authors = ["the rust-unofficial authors"] +description = "A catalogue of Rust design patterns, anti-patterns and idioms" +language = "en" +multilingual = false +src = "." + +[build] +create-missing = false + +[rust] +edition = "2018" + +[output.html] +default-theme = "rust" +git-repository-url = "https://github.com/rust-unofficial/patterns" +git-repository-icon = "fa-github" + +# [output.linkcheck] # enable the "mdbook-linkcheck" renderer, disabled due to gh-actions diff --git a/idioms/README.md b/idioms/README.md new file mode 100644 index 0000000..6b68019 --- /dev/null +++ b/idioms/README.md @@ -0,0 +1,3 @@ +# Idioms + +TODO: add description/explanation diff --git a/patterns/README.md b/patterns/README.md new file mode 100644 index 0000000..c80b437 --- /dev/null +++ b/patterns/README.md @@ -0,0 +1,3 @@ +# Design Patterns + +TODO: add description/explanation