docs: add initial Python documentation setup #71
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build docs | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: deploy | |
cancel-in-progress: false | |
jobs: | |
build-rust: | |
name: Build rustdoc | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Configure cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Clean docs folder | |
run: cargo clean --doc | |
- name: Build docs | |
run: RUSTFLAGS='--cfg reqwest_unstable' cargo doc --no-deps --manifest-path impit/Cargo.toml | |
- name: Remove lock file | |
run: rm target/doc/.lock | |
- name: Copy redirect | |
run: cp impit/docs/index.html target/doc/index.html | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: target/doc/ | |
name: rustdoc | |
build-node: | |
name: Build TypeDoc documentation (Node.JS bindings) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Configure cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v5 | |
with: | |
node-version: 24 | |
- name: Enable Corepack | |
run: | | |
corepack enable | |
corepack prepare yarn@stable --activate | |
- name: Activate cache for Node.js | |
uses: actions/setup-node@v5 | |
with: | |
node-version: 24 | |
cache: yarn | |
cache-dependency-path: impit-node/yarn.lock | |
- name: Install dependencies | |
run: cd impit-node && yarn | |
- name: Build docs | |
run: cd impit-node && yarn docs | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: impit-node/docs/ | |
name: typedoc | |
build-python: | |
name: Build Sphinx docs (Python bindings) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
- name: Use Python | |
uses: actions/setup-python@v6 | |
with: | |
python-version: 3.x | |
- name: Set up uv package manager | |
uses: astral-sh/setup-uv@v7 | |
- name: Install dependencies | |
working-directory: impit-python | |
run: | | |
uv venv | |
source .venv/bin/activate | |
uv sync --no-install-package impit --active | |
# comment out cookies module import | |
sed -i 's/from .cookies/#from .cookies/' ./python/impit/__init__.pyi | |
sed -i 's/from .cookies/#from .cookies/' ./python/impit/__init__.py | |
- name: Build docs | |
working-directory: impit-python/docs | |
run: | | |
source ../.venv/bin/activate | |
make html | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: impit-python/docs/_build/html | |
name: sphinx-doc | |
deploy: | |
name: Deploy | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: [build-rust, build-node] | |
steps: | |
- name: Download typedoc artifact | |
uses: actions/download-artifact@v5 | |
with: | |
name: typedoc | |
path: docs/ | |
- name: Setup pages | |
uses: actions/configure-pages@v5 | |
- name: Upload docs to github pages | |
uses: actions/upload-pages-artifact@v4 | |
with: | |
path: docs | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |