|
| 1 | +# Documentation Check |
| 2 | + |
| 3 | +The Soundness workflow can verify that your Swift package's [DocC](https://www.swift.org/documentation/docc/) documentation builds without warnings. Two jobs are available: |
| 4 | + |
| 5 | +- **`docs-check`** — runs on Linux. Enabled by default. |
| 6 | +- **`docs-check-macos`** — runs on a self-hosted macOS runner. Opt-in. |
| 7 | + |
| 8 | +Running both lets you catch documentation issues that only surface on one toolchain. |
| 9 | + |
| 10 | +Documentation warnings (and, by default, DocC analyzer findings) cause the job to fail. |
| 11 | + |
| 12 | +## Requirements |
| 13 | + |
| 14 | +### For both jobs |
| 15 | + |
| 16 | +1. **A `Package.swift`** (or any `Package*.swift`) at the repository root. |
| 17 | + |
| 18 | +2. **At least one documentation target**, supplied via either: |
| 19 | + - the `docs_check_targets` / `docs_check_macos_targets` input, **or** |
| 20 | + - a `documentation_targets` entry in a `.spi.yml` file at the repository root. |
| 21 | + |
| 22 | + If neither is provided, the job exits successfully without checking anything. |
| 23 | + |
| 24 | +The `.spi.yml` file is also where you can declare per-target DocC parameters via `custom_documentation_parameters`. Read the [official documentation](https://swiftpackageindex.com/SwiftPackageIndex/SPIManifest/1.12.0/documentation/spimanifest/commonusecases) for the full schema. For example: |
| 25 | + |
| 26 | +```yaml |
| 27 | +version: 1 |
| 28 | +builder: |
| 29 | + configs: |
| 30 | + - documentation_targets: [MyLibrary, MyOtherLibrary] |
| 31 | + custom_documentation_parameters: |
| 32 | + - --include-extended-types |
| 33 | +``` |
| 34 | +
|
| 35 | +Target names must match real SwiftPM target names declared in `Package.swift`. |
| 36 | + |
| 37 | +You do not need to add `swift-docc-plugin` to your package — CI provides it for you. |
| 38 | + |
| 39 | +### Additional requirement for the macOS job |
| 40 | + |
| 41 | +A self-hosted runner must be registered with the label set `[self-hosted, macos, <version>, <arch>]` matching the values you pass to `docs_check_macos_version` and `docs_check_macos_arch`, with the requested Xcode version installed. |
| 42 | + |
| 43 | +## Enabling the check |
| 44 | + |
| 45 | +Add (or extend) a workflow file under `.github/workflows/` in your repository: |
| 46 | + |
| 47 | +```yaml |
| 48 | +name: Pull request |
| 49 | +
|
| 50 | +on: |
| 51 | + pull_request: |
| 52 | + branches: [main] |
| 53 | +
|
| 54 | +jobs: |
| 55 | + soundness: |
| 56 | + name: Soundness |
| 57 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@<to-be-updated>> |
| 58 | + with: |
| 59 | + docs_check_enabled: true |
| 60 | +``` |
| 61 | + |
| 62 | +This enables the Linux documentation check along with the other soundness checks. The macOS variant remains off unless you opt in. |
| 63 | + |
| 64 | +## Configuration |
| 65 | + |
| 66 | +### Linux job (`docs-check`) |
| 67 | + |
| 68 | +| Input | Type | Default | Description | |
| 69 | +|---|---|---|---| |
| 70 | +| `docs_check_enabled` | boolean | `true` | Enable or disable the job. | |
| 71 | +| `docs_check_container_image` | string | `swift:6.2-noble` | Docker image used to run the check. | |
| 72 | +| `docs_check_targets` | string | `""` | Space-separated list of documentation targets to check. When empty, targets are read from `.spi.yml` (if present). | |
| 73 | +| `docs_check_additional_arguments` | string | `""` | Extra arguments to pass to DocC. | |
| 74 | +| `docs_check_analyze` | boolean | `true` | Set to `false` to skip DocC's analyzer pass. | |
| 75 | +| `linux_pre_build_command` | string | `""` | Shell command to run before the check (e.g., installing system dependencies). | |
| 76 | + |
| 77 | +### macOS job (`docs-check-macos`) |
| 78 | + |
| 79 | +| Input | Type | Default | Description | |
| 80 | +|---|---|---|---| |
| 81 | +| `docs_check_macos_enabled` | boolean | `false` | Enable or disable the job. | |
| 82 | +| `docs_check_macos_version` | string | `tahoe` | macOS version label of the runner to target. | |
| 83 | +| `docs_check_macos_arch` | string | `ARM64` | Architecture label of the runner to target. | |
| 84 | +| `docs_check_macos_xcode_version` | string | `26.0` | Xcode version to use. | |
| 85 | +| `docs_check_macos_targets` | string | `""` | Space-separated list of documentation targets to check. When empty, targets are read from `.spi.yml` (if present). | |
| 86 | +| `docs_check_macos_additional_arguments` | string | `""` | Extra arguments to pass to DocC. | |
| 87 | +| `docs_check_macos_analyze` | boolean | `true` | Set to `false` to skip DocC's analyzer pass. | |
| 88 | + |
| 89 | +The macOS job requires a self-hosted runner registered with the label set `[self-hosted, macos, <version>, <arch>]`. |
| 90 | + |
| 91 | +## Common scenarios |
| 92 | + |
| 93 | +### Enable the macOS check |
| 94 | + |
| 95 | +```yaml |
| 96 | +jobs: |
| 97 | + soundness: |
| 98 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main |
| 99 | + with: |
| 100 | + docs_check_macos_enabled: true |
| 101 | + docs_check_macos_version: "tahoe" |
| 102 | + docs_check_macos_arch: "ARM64" |
| 103 | + docs_check_macos_xcode_version: "26.0" |
| 104 | +``` |
| 105 | + |
| 106 | +### Check only specific targets |
| 107 | + |
| 108 | +By default the check documents every target listed in `.spi.yml`. To override that list without editing `.spi.yml`, provide the target names explicitly: |
| 109 | + |
| 110 | +```yaml |
| 111 | +jobs: |
| 112 | + soundness: |
| 113 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main |
| 114 | + with: |
| 115 | + docs_check_targets: "MyLibrary MyOtherLibrary" |
| 116 | +``` |
| 117 | + |
| 118 | +### Pin a different Swift toolchain or pass extra DocC flags |
| 119 | + |
| 120 | +```yaml |
| 121 | +jobs: |
| 122 | + soundness: |
| 123 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main |
| 124 | + with: |
| 125 | + docs_check_container_image: "swift:nightly-noble" |
| 126 | + docs_check_additional_arguments: "--include-extended-types" |
| 127 | + linux_pre_build_command: "apt-get update && apt-get install -y libxml2-dev" |
| 128 | +``` |
| 129 | + |
| 130 | +### Skip the DocC analyzer |
| 131 | + |
| 132 | +```yaml |
| 133 | +jobs: |
| 134 | + soundness: |
| 135 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main |
| 136 | + with: |
| 137 | + docs_check_analyze: false |
| 138 | +``` |
| 139 | + |
| 140 | +### Disable the check |
| 141 | + |
| 142 | +If you want to skip the documentation check entirely (regardless of whether your package has documentation targets), turn it off: |
| 143 | + |
| 144 | +```yaml |
| 145 | +jobs: |
| 146 | + soundness: |
| 147 | + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main |
| 148 | + with: |
| 149 | + docs_check_enabled: false |
| 150 | +``` |
| 151 | + |
| 152 | +If you simply have no documentation targets to check, you can leave the job enabled — it will exit successfully without doing anything. |
| 153 | + |
| 154 | +## Troubleshooting |
| 155 | + |
| 156 | +| Symptom | Likely cause | |
| 157 | +|---|---| |
| 158 | +| Job logs `No '.spi.yml' found, no documentation targets to check.` and exits successfully. | Neither `docs_check_targets` nor a `.spi.yml` was provided. Add one of them if you expected the check to run. | |
| 159 | +| `Package.swift not found.` | The check expects a SwiftPM package at the repo root. | |
| 160 | +| Warnings cause the job to fail. | Intentional. Resolve the DocC warnings, or pass DocC flags via `.spi.yml`'s `custom_documentation_parameters` to suppress them. | |
| 161 | +| macOS job stays queued. | No self-hosted runner matches the requested labels. Verify the `version` and `arch` inputs against your runner inventory. | |
| 162 | +| macOS job cannot find Xcode. | The requested Xcode version is not installed on the runner. | |
0 commit comments