From f5ca177184ac3b5d79daaba126e25bd1ebb6dafc Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Thu, 29 Jun 2023 22:06:54 +0200 Subject: [PATCH] Build Documentation with GitHub Actions --- .github/workflows/build.yml | 6 +-- .github/workflows/docs.yml | 73 +++++++++++++++++++++++++++++++++++++ README.md | 2 + src/lib.rs | 1 + 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4939aa..720f5fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout Commit - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust uses: hecrj/setup-rust-action@v1 @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Commit - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust uses: hecrj/setup-rust-action@v1 @@ -77,7 +77,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Commit - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Rust uses: hecrj/setup-rust-action@v1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..833ad38 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,73 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy docs + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust + uses: hecrj/setup-rust-action@v1 + with: + components: rust-docs + rust-version: nightly + targets: wasm32-wasi + + - name: Build docs + run: RUSTDOCFLAGS="--cfg doc_cfg" cargo doc --all-features --target wasm32-wasi + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Fix file permissions + shell: sh + if: runner.os == 'Linux' + run: | + chmod -c -R +rX "$INPUT_PATH" | + while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + tar \ + --dereference --hard-dereference \ + --directory "$INPUT_PATH" \ + -cvf "$RUNNER_TEMP/artifact.tar" \ + --exclude=.git \ + --exclude=.github \ + . + env: + INPUT_PATH: target/wasm32-wasi/doc + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: target/wasm32-wasi/doc + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/README.md b/README.md index 1db64b7..14c6cff 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Helper crate to write auto splitters for LiveSplit One's auto splitting runtime. +[API Documentation](https://livesplit.org/asr/asr/) + There are two ways of defining an auto splitter. ## Defining an `update` function diff --git a/src/lib.rs b/src/lib.rs index d367f7a..4ddf8b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ missing_docs, rust_2018_idioms )] +#![cfg_attr(doc_cfg, feature(doc_auto_cfg))] //! Helper crate to write auto splitters for LiveSplit One's auto splitting //! runtime.