Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

Commit 093149c

Browse files
committed
fix(swift-doc-coverage): gracefully skip when swift-docc-plugin is missing
SwiftPM returns exit 64 with stderr `Unknown subcommand or plugin name 'generate-documentation'` when the package plugin that provides the subcommand isn't on the consumer Package.swift's dependency list. The hook now detects that exact error and emits a one-line skip notice pointing at the missing dependency, matching the existing 'swift not on PATH' skip path. Without this, every consumer repo whose Package.swift does not declare swift-docc-plugin fails CI Lint on every commit. Also adds .typos.toml with BRE/ERE POSIX acronyms allow-listed so a pre-existing CHANGELOG entry stops tripping the typos hook on touch.
1 parent 5746de1 commit 093149c

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

.typos.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[default.extend-words]
2+
# Technical acronyms that typos misidentifies.
3+
BRE = "BRE" # Basic Regular Expression (POSIX)
4+
ERE = "ERE" # Extended Regular Expression (POSIX)

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.1.19] - 2026-05-26
11+
12+
### Added
13+
14+
- `.typos.toml` with `BRE`/`ERE` POSIX regex acronyms allow-listed so the
15+
typos hook stops flagging legitimate technical terms used in CHANGELOG and
16+
hook documentation. (`.typos.toml`)
17+
1018
### Changed
1119

1220
- Bump pinned versions in `.pre-commit-config.yaml`: `astral-sh/ruff-pre-commit`
@@ -16,6 +24,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1624

1725
### Fixed
1826

27+
- `swift-doc-coverage`: gracefully skip when `swift-docc-plugin` is not a
28+
declared dependency of the target `Package.swift`. SwiftPM returns exit 64
29+
with stderr `Unknown subcommand or plugin name 'generate-documentation'`
30+
when the package plugin that provides the subcommand isn't on the package's
31+
dependency list. The hook now detects that exact error and emits a one-line
32+
skip notice (pointing at the missing dependency) instead of failing the
33+
commit, matching the existing "swift not on PATH" skip behaviour. Without
34+
this, every consumer repo that ships a Package.swift without DocC support
35+
fails CI Lint on every commit. (`hooks/swift-doc-coverage/run.sh`)
36+
1937
- `oxfmt`: refresh v1.66.0 checksums after the upstream asset changed from the
2038
stale v1.64.0 digest. This fixes checksum failures on macOS arm64 consumers.
2139
(`hooks/oxfmt/checksums.txt`)

hooks/swift-doc-coverage/run.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# --warnings-as-errors`. Captures stderr for "missing documentation" or
66
# "broken documentation link" warnings and fails on any match.
77
# If `swift` is not on PATH or no Package.swift is found, exits 0.
8+
# shellcheck disable=SC2016
9+
# Single-quoted printf messages intentionally contain literal backticks to
10+
# render tool/path names in the shell output; we do not want shell expansion.
811
set -euo pipefail
912

1013
if ! command -v swift >/dev/null 2>&1; then
@@ -71,6 +74,21 @@ for root in "${roots[@]}"; do
7174
rc=$?
7275
set -e
7376

77+
# `swift package generate-documentation` is provided by the swift-docc-plugin
78+
# package plugin. When the consumer's Package.swift does not declare
79+
# `swift-docc-plugin` as a dependency, SwiftPM returns exit 64 with stderr
80+
# `Unknown subcommand or plugin name 'generate-documentation'`. The hook
81+
# cannot enforce doc coverage in that case, so emit a one-line skip notice
82+
# pointing at the missing dependency and move on instead of failing the
83+
# commit. This matches the existing "swift not on PATH" skip behaviour.
84+
if ((rc != 0)) && grep -E -q "Unknown subcommand or plugin name .?generate-documentation" "${log_file}"; then
85+
printf 'swift-doc-coverage: skipping %s — swift-docc-plugin is not declared as a Package.swift dependency.\n' "${root}" >&2
86+
printf " add \`.package(url: \"https://github.com/swiftlang/swift-docc-plugin\", from: \"1.4.0\")\` to enable this hook.\n" >&2
87+
rm -f "${log_file}"
88+
trap - EXIT
89+
continue
90+
fi
91+
7492
cat "${log_file}" >&2
7593

7694
if ((rc != 0)); then

0 commit comments

Comments
 (0)