diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..33b8e09 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,52 @@ +# API reference: one DocC archive per module (the .docc catalogs under Sources/), merged into one static site and +# published to GitHub Pages at https://mac4dstem.github.io/SimulatoKit/documentation/ on every tag. +# On a pull request the site is built and uploaded as an artifact only, so a broken catalog fails before the tag. +# +# No swift-docc-plugin: the kit takes no package dependencies (CLAUDE.md). `xcodebuild docbuild` builds the archives +# from the package's own schemes; `docc merge` (Xcode 16+) joins them. Needs Pages enabled with source "GitHub Actions" +# (repository Settings > Pages). Copied from CuboKit's pattern; the module list is read from the .docc catalogs. +name: Docs + +on: + push: + tags: ['*'] + pull_request: + paths: ['Sources/**/*.docc/**', '.github/workflows/docs.yml', 'tools/build-docs.sh'] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: macos-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + - name: Select the newest Xcode + run: | + xcode=$(ls -d /Applications/Xcode*.app | sort -V | tail -1) + sudo xcode-select -s "$xcode" + xcodebuild -version + - name: Build the site + run: tools/build-docs.sh .docs-site /SimulatoKit + - uses: actions/upload-pages-artifact@v3 + with: + path: .docs-site + + deploy: + needs: build + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 4114e8e..5bb4aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .swiftpm/ *.xcresult /Examples/output/ +.docs-site/ diff --git a/Tests/Fixtures/README.md b/Tests/Fixtures/README.md new file mode 100644 index 0000000..476fa00 --- /dev/null +++ b/Tests/Fixtures/README.md @@ -0,0 +1,21 @@ +# Test fixtures + +One row per committed fixture file under `Tests/*/Fixtures/`: size, the script under `tools/` that names it (the generator or its +pin script; a few scripts write a whole directory; a script found only by file-name prefix, tool-folder name or test module is marked so), and a note where the origin is not the kit's own pinned reference. 10 files. + +Licence: every fixture is generated from this kit's own code and the pinned Python reference (see `CLAUDE.md`, Reference) and ships under the kit's GPL-3.0-or-later licence, except the rows marked *third party*. Nothing here is the owner's data: the committed text fixtures carry no owner path or name (checked by search), and real datasets are read from `$MACEM_DATA` and never copied into the repo. + +## All fixtures + +| File | Size | Generated by | Note | +|---|---|---|---| +| `SimulatoKitParityTests/Fixtures/slice-1-arrays.bin` | 12.7 MB | `tools/slice-1/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-1-pins.json` | 169.8 KB | `tools/slice-1/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-2-arrays.bin` | 1.4 MB | `tools/slice-2/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-2-pins.json` | 43.3 KB | `tools/slice-2/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-3-arrays.bin` | 1.5 MB | `tools/slice-3/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-3-pins.json` | 7.2 KB | `tools/slice-3/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-4-arrays.bin` | 421.9 KB | `tools/slice-4/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-4-pins.json` | 2.6 KB | `tools/slice-4/pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-4-scan-arrays.bin` | 1.2 MB | `tools/slice-4/scan_pins.py` | | +| `SimulatoKitParityTests/Fixtures/slice-4-scan-pins.json` | 1.3 KB | `tools/slice-4/scan_pins.py` | | diff --git a/tools/build-docs.sh b/tools/build-docs.sh new file mode 100755 index 0000000..127890f --- /dev/null +++ b/tools/build-docs.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Builds the DocC site for every module with a .docc catalog and merges it into one static site. +# tools/build-docs.sh [] e.g. tools/build-docs.sh .docs-site /SimulatoKit +# macOS with Xcode 16 or later. Output is gitignored (.docs-site). +set -euo pipefail +cd "$(dirname "$0")/.." +out="${1:?output dir}" +base="${2:-}" +derived="$(mktemp -d)" +trap 'rm -rf "$derived"' EXIT + +modules=$(find Sources -maxdepth 2 -name '*.docc' -exec basename {} .docc \; | sort) +archives=() +for m in $modules; do + xcodebuild docbuild -scheme "$m" -destination 'generic/platform=macOS' -derivedDataPath "$derived" >"$derived/$m.log" 2>&1 \ + || { tail -30 "$derived/$m.log"; echo "docbuild failed for $m"; exit 1; } + archives+=("$(find "$derived/Build/Products" -name "$m.doccarchive" -maxdepth 3 | head -1)") +done + +merged="$derived/SimulatoKit.doccarchive" +xcrun docc merge "${archives[@]}" --output-path "$merged" +rm -rf "$out" +xcrun docc process-archive transform-for-static-hosting "$merged" --output-path "$out" ${base:+--hosting-base-path "$base"} +# the site root has no page of its own: send it to the merged documentation landing page +printf '' "${base}" > "$out/index.html" +echo "built $out ($(echo "$modules" | wc -l | tr -d ' ') modules)"