|
| 1 | +name: Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + # Only PRs targeting master (base branch = master) and pushes to master. |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + branches: [master] |
| 8 | + paths: |
| 9 | + - "docs/**" |
| 10 | + - "rocketpy/**" # docstrings feed the autodoc API reference |
| 11 | + - "pyproject.toml" |
| 12 | + - "requirements*" |
| 13 | + - ".readthedocs.yaml" |
| 14 | + - ".github/workflows/docs.yml" |
| 15 | + push: |
| 16 | + branches: [master] |
| 17 | + paths: |
| 18 | + - "docs/**" |
| 19 | + - "rocketpy/**" |
| 20 | + - "pyproject.toml" |
| 21 | + - "requirements*" |
| 22 | + - ".readthedocs.yaml" |
| 23 | + - ".github/workflows/docs.yml" |
| 24 | + |
| 25 | +defaults: |
| 26 | + run: |
| 27 | + shell: bash |
| 28 | + |
| 29 | +jobs: |
| 30 | + build-docs: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + python-version: ["3.12"] # match the Read the Docs build environment |
| 35 | + env: |
| 36 | + MPLBACKEND: Agg |
| 37 | + # Render jupyter-execute cells as static code blocks instead of running |
| 38 | + # them. This keeps the check fast and deterministic: no simulations and, |
| 39 | + # crucially, no live network calls to external weather/data servers (which |
| 40 | + # make the full build slow and flaky). Read the Docs still executes the |
| 41 | + # cells to render live outputs; this job only validates the docs structure |
| 42 | + # (reStructuredText, cross-references, toctrees, autodoc API reference). |
| 43 | + DOCS_SKIP_EXECUTE: "1" |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@main |
| 46 | + |
| 47 | + - name: Install pandoc (required by nbsphinx) |
| 48 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 49 | + |
| 50 | + - name: Set up Python ${{ matrix.python-version }} |
| 51 | + uses: actions/setup-python@main |
| 52 | + with: |
| 53 | + python-version: ${{ matrix.python-version }} |
| 54 | + cache: "pip" |
| 55 | + cache-dependency-path: | |
| 56 | + docs/requirements.txt |
| 57 | + requirements.txt |
| 58 | +
|
| 59 | + - name: Install dependencies (mirrors .readthedocs.yaml) |
| 60 | + run: | |
| 61 | + python -m pip install --upgrade pip |
| 62 | + pip install -r docs/requirements.txt |
| 63 | + pip install -r requirements.txt |
| 64 | + pip install .[all] |
| 65 | +
|
| 66 | + - name: Cache Sphinx doctrees |
| 67 | + uses: actions/cache@main |
| 68 | + with: |
| 69 | + path: docs/_build/doctrees |
| 70 | + key: sphinx-doctrees-${{ github.ref }}-${{ hashFiles('docs/**', 'rocketpy/**') }} |
| 71 | + restore-keys: | |
| 72 | + sphinx-doctrees-${{ github.ref }}- |
| 73 | + sphinx-doctrees- |
| 74 | +
|
| 75 | + - name: Build docs (warnings-as-errors) |
| 76 | + working-directory: docs |
| 77 | + run: | |
| 78 | + sphinx-build -b html -W --keep-going \ |
| 79 | + -d _build/doctrees \ |
| 80 | + -w _build/sphinx-warnings.txt \ |
| 81 | + . _build/html |
| 82 | +
|
| 83 | + - name: Surface Sphinx warnings as annotations |
| 84 | + if: always() |
| 85 | + run: | |
| 86 | + if [ -s docs/_build/sphinx-warnings.txt ]; then |
| 87 | + echo "::group::Sphinx warnings" |
| 88 | + cat docs/_build/sphinx-warnings.txt |
| 89 | + echo "::endgroup::" |
| 90 | + while IFS= read -r line; do |
| 91 | + echo "::warning::${line}" |
| 92 | + done < docs/_build/sphinx-warnings.txt |
| 93 | + else |
| 94 | + echo "No Sphinx warnings 🎉" |
| 95 | + fi |
| 96 | +
|
| 97 | + - name: Upload built HTML |
| 98 | + if: always() |
| 99 | + uses: actions/upload-artifact@main |
| 100 | + with: |
| 101 | + name: docs-html |
| 102 | + path: docs/_build/html |
| 103 | + if-no-files-found: error |
0 commit comments