Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Demian101 committed Oct 24, 2023
1 parent 8f697ef commit 4789040
Show file tree
Hide file tree
Showing 26 changed files with 4,903 additions and 17 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
#
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
#
name: Deploy mdBook site to Pages
name: Deploy z2o-k7e to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths:
- "src/**"
- "po/**"
- "theme/**"
- "justfile"
- "book.toml"
- .github/workflows/mdbook.yml

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -28,22 +35,31 @@ jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.21
steps:
- uses: actions/checkout@v3
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook

# Init build environment
# - name: Install just
# run: |
# curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | sudo bash -s -- --to /bin
# - name: Install cargo
# run: |
# curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
# rustup update
- name: Init build environment
run: just init-builder

# Build
- name: Build with mdBook
run: just build

# Upload artifact for Github pages
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build with mdBook
run: mdbook build

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v1
with:
path: ./book

Expand All @@ -57,4 +73,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v2
52 changes: 49 additions & 3 deletions book.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
[book]
authors = ["Demian"]
language = "en"
authors = ["Creators!"]
language = "cn"
multilingual = false
src = "src"
title = "Creators World."
title = "Creators' World."
description = "零知世界"


[preprocessor]

# [preprocessor.katex]
# after = ["links"]
# macros = "macros.txt"

[preprocessor.toc]
command = "mdbook-toc"
renderer = ["html"]
marker = "[TOC]"
max-level = 4

[preprocessor.admonish]
command = "mdbook-admonish"
assets_version = "3.0.0" # do not edit: managed by `mdbook-admonish install`

[preprocessor.open-on-gh]
command = "mdbook-open-on-gh"
renderer = ["html"]


[preprocessor.mermaid]
command = "mdbook-mermaid"


[output.html]
mathjax-support = true
no-section-label = true
theme = "theme"
additional-js = ["theme/mermaid.min.js", "theme/mermaid-init.js"]
additional-css = ["./mdbook-admonish.css", "theme/css/mdbook-admonish.css", "theme/css/open-in.css"]
git-repository-url = "https://github.com/zkp-co-learning/zkp-co-learning.github.io"
open-on-text = "Found a bug?! [Edit this page on GitHub.]"
edit-url-template = "https://github.com/zkp-co-learning/zkp-co-learning.github.io/edit/main/{path}"
curly-quotes = true # replaces straight quotes with curly quotes


[output.html.fold]
enable = true # whether or not to enable section folding
level = 0 # the depth to start folding

[output.html.search]
enable = true
64 changes: 64 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env just --justfile

COLOR_GREEN := 'Green'
COLOR_BLUE := 'Blue'
COLOR_RED := 'Red'

ROOT_DIR := replace(justfile_directory(), "\\", "/")

set shell := ["pwsh", "-NoLogo", "-Command"]

#
# Build tasks
#
default: serve

init:
# cargo install mdbook
cargo install mdbook-admonish
cargo install mdbook-mermaid
cargo install mdbook-open-on-gh
cargo install mdbook-toc

init-builder:
# @just install-gh-bin https://github.com/rust-lang/mdBook/releases/download/v0.4.35/mdbook-v0.4.35-x86_64-unknown-linux-gnu.tar.gz mdbook
# cargo install mdbook-i18n-helpers
@just install-gh-bin https://github.com/badboy/mdbook-mermaid/releases/download/v0.12.6/mdbook-mermaid-v0.12.6-x86_64-unknown-linux-gnu.tar.gz mdbook-mermaid
@just install-gh-bin https://github.com/badboy/mdbook-open-on-gh/releases/download/2.4.1/mdbook-open-on-gh-2.4.1-x86_64-unknown-linux-gnu.tar.gz mdbook-open-on-gh
# @just install-gh-bin https://github.com/lzanini/mdbook-katex/releases/download/v0.5.8pub/mdbook-katex-v0.5.8-x86_64-unknown-linux-gnu.tar.gz mdbook-katex
@just install-gh-bin https://github.com/badboy/mdbook-toc/releases/download/0.14.1/mdbook-toc-0.14.1-x86_64-unknown-linux-gnu.tar.gz mdbook-toc
@just install-gh-bin https://github.com/tommilligan/mdbook-admonish/releases/download/v1.13.0/mdbook-admonish-v1.13.0-x86_64-unknown-linux-gnu.tar.gz mdbook-admonish

install-gh-bin GITHUB_PATH BIN_NAME:
@just _log-head "Installing {{BIN_NAME}} from {{GITHUB_PATH}} ..."
rm -f bin.tar.gz
wget {{GITHUB_PATH}} -O bin.tar.gz
tar zxvf ./bin.tar.gz
chmod +x ./{{BIN_NAME}}
mv ./{{BIN_NAME}} ~/.cargo/bin
@just _log-info "Installing {{BIN_NAME}} completed!"

build:
@just _log-head "Building book ..."
mdbook build
just po-build en

serve:
@just _log-head "Starting mdbook server ..."
mdbook serve -n 0.0.0.0


#
# Utility tasks
#
_log-head LOG_LINE:
@just _log-inner "{{COLOR_GREEN}}" "INFO!" "{{LOG_LINE}}"

_log-info LOG_LINE:
@just _log-inner "{{COLOR_BLUE}}" "INFO " "{{LOG_LINE}}"

_log-error LOG_LINE:
@just _log-inner "{{COLOR_RED}}" "ERROR" "{{LOG_LINE}}"

_log-inner COLOR LOG_LEVEL LOG_LINE:
@if ("{{LOG_LINE}}" -eq "") { echo ""; } else { Write-Host -ForegroundColor "{{COLOR}}" "[$(Get-Date -UFormat '%Y-%m-%d %H:%M:%S')][{{LOG_LEVEL}}] {{LOG_LINE}}"; }
Loading

0 comments on commit 4789040

Please sign in to comment.