Skip to content

Fix trait conflict that broke the Swift Package Index doc build - #412

Merged
trasch merged 1 commit into
mainfrom
fix/trait-docs-spi
Oct 30, 2026
Merged

trasch merged 1 commit into
mainfrom
fix/trait-docs-spi

Conversation

@trasch

@trasch trasch commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Problem

The DocC pages on Swift Package Index were never published. The documentation
build was failing, not merely stale — SPI's builder extracts symbol graphs
with every package trait enabled, which hit this in IntExtensions.swift:

-DEnableGraphAPI -DEnableMeasurementExtensions -DEnableMeterConversionExtensions
error: EnableMeterConversionExtensions and EnableMeasurementConversionExtensions are mutually exclusive
error: Build failed
Error while generating docs: retryLimitExceeded(...)
✅  Doc result (failed) reported

Every doc build since the traits landed in #118 failed, so the served archive
predates the DocC catalog: it contains no articles (gettingstarted,
csv, mvttools, … all 404) and no Graph API pages.

The same #error also made swift build --enable-all-traits unusable.

Fix

Traits are alternatives, not complements. IntExtensions.swift and
DoubleExtensions.swift now use one #if … #elseif block instead of two
independent blocks plus an #error. EnableMeasurementConversionExtensions
wins when both are on, so enabling everything still compiles.

CI could not have caught this. scripts/check_documentation.py built with
default traits only. It now builds and extracts symbol graphs with
--enable-all-traits, mirroring SPI. That surfaced five Graph-trait DocC
warnings, all fixed:

File Warning
Graph+BetweennessCentrality.swift articulationPoints()|articulation point doesn't exist
Graph+Eulerian.swift eulerianity() == .eulerian doesn't exist
Graph.swift nodeOnEdge(near:) doesn't exist
Graph+Contraction.swift expandPath(_:) doesn't exist
Graph+Contraction.swift Parameter result is missing documentation

README attribution. The intro and feature list credited every algorithm to
turf.js. They now name the actual sources: turf.js, GEOS, PROJ, Mapbox
polylabel, and implementations written from scratch. The missing
mvt-tools guide is added to the documentation list.

Cross-page links. <doc:FIT> renders as the literal text doc:FIT on
GitHub. Prose links now use reference-style definitions pointing at the hosted
SPI pages, so they work on both GitHub and SPI:

[FIT][fit], [GeoPackage][geopackage]

[fit]: https://swiftpackageindex.com/Outdooractive/gis-tools/documentation/gistools/fit
[geopackage]: https://swiftpackageindex.com/Outdooractive/gis-tools/documentation/gistools/geopackage

The ## Topics lists in GISTools.md keep doc: links — DocC rejects
absolute URLs there, and GitHub renders [Title](doc:Target) as just the
title, which reads fine on an index page.

Verification

  • swift build — clean, no warnings
  • swift build --enable-all-traits — now succeeds (failed before)
  • swift test --traits EnableGraphAPI — 3071 tests / 210 suites pass
  • swift test --enable-all-traits — 3071 tests pass
  • swift test --traits EnableMeterConversionExtensions / …MeasurementConversionExtensions — 2715 tests each
  • python3 scripts/check_documentation.py — 0 diagnostics (5 before)
  • Coverage: 90.37% (gate 87.5%)
  • SwiftFormat: no new violations on any changed file (compared per-file against main)
  • Archive now contains all 13 articles and 118 Graph pages

After merge

SPI re-processes main within 24 hours, but processes a release
immediately
. Tag v3.0.2 to publish the docs right away.

AI assistance

Developed with AI assistance (DeepSeek V4.1 Flash, via OpenCode).

The SPI documentation builder extracts symbol graphs with every package
trait enabled. EnableMeterConversionExtensions and
EnableMeasurementConversionExtensions were declared mutually exclusive via
an #error, so every doc build since the traits landed failed and the hosted
archive stayed stale: it contained neither the DocC articles nor the Graph
API. The same #error also made `swift build --enable-all-traits` unusable.

Make the two traits alternatives rather than complements: a single
#if/#elseif block, with EnableMeasurementConversionExtensions winning when
both are on. Verified with the default build, each trait alone,
EnableGraphAPI and --enable-all-traits.

Build the DocC catalog with all traits enabled in check_documentation.py so
CI mirrors SPI and catches this class of failure. That surfaced five
Graph-trait symbol-link warnings, now fixed.

Replace the turf.js-only attribution in the README with the actual sources:
turf.js, GEOS, PROJ, Mapbox polylabel and from-scratch implementations. Add
the missing mvt-tools guide to the documentation list.

Cross-page catalog links used <doc:...>, which GitHub renders as literal
text. Prose links now use reference-style definitions pointing at the
hosted SPI pages, so they work on both GitHub and Swift Package Index.
The Topics lists keep doc: links, because DocC rejects absolute URLs there.

Adds a test pinning the trait precedence rule.
@trasch trasch self-assigned this Oct 30, 2026
@trasch trasch added the documentation Improvements or additions to documentation label Oct 30, 2026
@trasch
trasch merged commit 5ca665d into main Oct 30, 2026
6 checks passed
@trasch
trasch deleted the fix/trait-docs-spi branch October 30, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant