diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..f6b67bcc4 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,88 @@ +# Build and deploy documentation using Sphinx +# +# On pull requests: builds docs to verify they compile without errors. +# On pushes to main: builds and deploys to GitHub Pages. +# +# This workflow is documentation-tooling agnostic — it runs whichever +# Sphinx build is configured in docs/conf.py. If the project switches +# to Jupyter Book or another Sphinx-based tool, only the install step +# and build command need updating. +name: Documentation + +on: + push: + branches: [main] + paths: + - "docs/**" + - "neural_lam/**" + - ".github/workflows/docs.yml" + pull_request: + branches: [main] + paths: + - "docs/**" + - "neural_lam/**" + - ".github/workflows/docs.yml" + +# Allow only one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: false + +permissions: + contents: read + pages: write + id-token: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v6 + with: + python-version: "3.12" + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y graphviz + + - name: Install neural-lam and doc dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e . + python -m pip install -r docs/requirements.txt + + - name: Build documentation + working-directory: docs + run: | + sphinx-build -b html . _build/html -W --keep-going -n + env: + MPLBACKEND: Agg + + - name: Check for broken links + working-directory: docs + continue-on-error: true + run: | + sphinx-build -b linkcheck . _build/linkcheck + + - name: Upload documentation artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: docs/_build/html + + deploy: + needs: build + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..d45634673 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,7 @@ +# Documentation build dependencies +# Install with: pip install -r docs/requirements.txt +sphinx>=7.0 +pydata-sphinx-theme>=0.15 +sphinx-autoapi>=3.0 +numpydoc>=1.6 +sphinx-copybutton>=0.5