name: Build Documentation

on:
  push:
    branches: [ main ]

jobs:
  deploy-docs:
    runs-on: ubuntu-latest

    permissions:
      contents: write  # nécessaire pour push sur gh-pages

    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Install Rust (stable + clippy + rustfmt)
        uses: dtolnay/rust-toolchain@stable
      - name: Build docs
        run: cargo doc --no-deps --document-private-items --all-features

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./target/doc
          force_orphan: true
