Skip to content

Fix documentation, test hygiene and CI - #116

Merged
trasch merged 3 commits into
mainfrom
docs-and-ci
Nov 2, 2026
Merged

trasch merged 3 commits into
mainfrom
docs-and-ci

Conversation

@trasch

@trasch trasch commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Documentation that contradicted the code, tests that could not fail, and CI that could not catch regressions. This PR fixes all three, and adopts the fuller gis-tools style section in AGENTS.md.

Documentation

Claim Reality
Package layout listed 8 files 12 files exist (FeatureQuery, MapnikError, RenderOptions, WorkQueue, MapnikPool were missing)
Datasource examples used epsg:3857 for GeoJSON GeoJSON is lon/lat; unprojExtent came out wrong
var generator = TileGenerator(...) final class, let is correct
["all": builder.tilelist] Tilelist already carries all; this double-wrapped it
"PNG (8/24/32-bit)" Only 32-bit, png256 and png:c=N exist
"lossless-ish WebP" mapnik's default is lossy quality 80
"Every public symbol carries a doc comment" Several did not
"no external data is needed" The suite needs DejaVu fonts and the GDAL plugin
MetatileOptions example Called renderMetatile(x:y:z:options:) and tile(x:y:), neither of which exists
"default bufferSize of 16" The default is nil (stylesheet buffer)

Also: added the missing doc comments, fixed DocC symbol links that did not resolve, and deprecated QueriedFeature (no API produces it).

swift package generate-documentation --warnings-as-errors now succeeds; it found the broken links.

AGENTS.md

Adopted gis-tools' fuller style section — spacing, colon style, ternary formatting, attributes, number literals, code organization, argument wrapping and test naming — and corrected the file map, the @unchecked Sendable list and the test requirements.

Tests

  • All 121 backticked test names are now camelCase with a /// line, per the updated .swiftformat (--test-case-name-format preserve) and the repo convention.
  • New TilelistBuilderTests — TilelistBuilder had zero tests despite being a public type with a documented JSON schema. Now covers ranges, gaps, grouping, duplicates, the exact JSON shape, Codable round trip and concurrent adds.
  • rendering same map twice is stable asserted first?.count == second?.count, which is true for any two PNGs of the same tile. It now asserts byte equality.
  • The label test accepted an empty tile; it now requires painted pixels.
  • The unknown-datasource test passed when no error was thrown; it now requires one.
  • The label and raster tests skip when DejaVu or GDAL is missing, instead of failing on such a machine.

CI

Job Purpose
format swiftformat --lint (the repo did not pass its own config)
sanitizer swift test --sanitize=thread for the @unchecked Sendable types
docs DocC with --warnings-as-errors
macos / linux now also build -c release

The build cache is now keyed on the installed mapnik version, so a runner image bump no longer reuses objects compiled against the old library.

Testing

89 tests pass across the affected suites; the full run has only the two pre-existing saveXML(explicitDefaults:) failures, fixed in #111.

Closes #31
Closes #33
Closes #34
Closes #36
Closes #53
Closes #68
Closes #69
Closes #70
Closes #71
Closes #72
Closes #75
Closes #76
Closes #77
Closes #81
Closes #89
Closes #100
Closes #101
Closes #102
Closes #106
Closes #107

Documentation
- README: the package layout now matches the actual files (FeatureQuery,
  MapnikError, RenderOptions, WorkQueue, MapnikPool were missing).
- README: the datasource examples pass epsg:4326 for GeoJSON data instead
  of epsg:3857, which made unprojExtent wrong.
- README: the bulk-rendering examples use `let` for the final class
  generators, and the tilelist example no longer double-wraps "all".
- README: "8/24/32-bit PNG" and "lossless-ish WebP" were inaccurate; both
  now describe what the API actually produces.
- README: the documentation section explains that swift-docc-plugin must
  be added first, and the tests section lists the DejaVu font and GDAL
  plugin requirements.
- MetatileOptions' DocC example called two APIs that do not exist.
- renderMetatile's doc claimed a default bufferSize of 16; the default is
  nil (stylesheet buffer).
- Added the missing doc comments on public symbols in TileSequence,
  TilelistBuilder, RenderOptions and MapnikDatasource.
- Fixed DocC symbol links that did not resolve (inspect, queryBox,
  queryPoint) and deprecated QueriedFeature, which no API produces.

AGENTS.md
- Adopted gis-tools' fuller style section: spacing, colon style, ternary
  formatting, attributes, number literals, code organization, argument
  wrapping and test naming.
- Corrected the file map (FeatureQuery.swift, Extensions) and the
  @unchecked Sendable list (MetatileGenerator, MapnikDatasource).
- Documented the DejaVu/GDAL test requirements and the camelCase test
  naming convention.

Tests
- All 121 backticked test names are camelCase identifiers with a /// line,
  per the updated .swiftformat (--test-case-name-format preserve) and the
  repo convention.
- New TilelistBuilderTests: ranges, gaps, grouping, duplicates, the exact
  JSON shape, Codable round trip and concurrent adds. TilelistBuilder had
  no tests at all.
- "rendering same map twice is stable" now asserts byte equality instead
  of equal length, which could not fail.
- The label test asserts that pixels were painted instead of accepting an
  empty tile.
- The unknown-datasource test requires an error instead of passing when
  none is thrown.
- The label and raster tests are skipped when the DejaVu face or the GDAL
  plugin is missing, instead of failing on such a machine.

CI
- New format job running swiftformat --lint.
- New sanitizer job running the suite under --sanitize=thread for the
  @unchecked Sendable pool/queue/datasource types.
- New docs job building DocC with --warnings-as-errors.
- Release builds on macOS and Linux.
- The build cache is keyed on the installed mapnik version, so a runner
  image bump no longer reuses objects built against the old library.

Fixes #31
Fixes #33
Fixes #34
Fixes #36
Fixes #37
Fixes #53
Fixes #68
Fixes #69
Fixes #70
Fixes #71
Fixes #72
Fixes #75
Fixes #76
Fixes #77
Fixes #81
Fixes #89
Fixes #101
Fixes #106
Fixes #107
Rebased onto main after #111-#115 landed. The conflicts were all in code the
earlier PRs already fixed, so main's version was kept and only this PR's own
changes were re-applied.

Documentation
- README: package layout matches the actual files, datasource examples use
  epsg:4326 for GeoJSON data, the bulk-rendering examples use `let` for the
  final class generators, and the tilelist example no longer double-wraps
  "all".
- README: "8/24/32-bit PNG" and "lossless-ish WebP" now describe what the
  API actually produces, the documentation section explains that
  swift-docc-plugin must be added first, and the tests section lists the
  DejaVu font and GDAL plugin requirements.
- MetatileOptions' DocC example called two APIs that do not exist.
- renderMetatile's doc claimed a default bufferSize of 16; the default is
  nil (stylesheet buffer).
- Added the missing doc comments on public symbols and fixed DocC symbol
  links that did not resolve; QueriedFeature is deprecated.

AGENTS.md
- Adopted gis-tools' fuller style section and corrected the file map, the
  @unchecked Sendable list and the test requirements.

Tests
- All 176 backticked test names are camelCase identifiers with a /// line,
  per the updated .swiftformat (--test-case-name-format preserve).
- New TilelistBuilderTests: ranges, gaps, grouping, duplicates, the exact
  JSON shape, Codable round trip and concurrent adds. TilelistBuilder had
  no tests at all.
- "rendering same map twice is stable" asserts byte equality instead of
  equal length, which could not fail.
- The label test asserts that pixels were painted instead of accepting an
  empty tile.
- The unknown-datasource test requires an error instead of passing when
  none is thrown.
- The label and raster tests are skipped when the DejaVu face or the GDAL
  plugin is missing.

CI
- New format job (swiftformat --lint), sanitizer job (--sanitize=thread),
  and docs job (DocC --warnings-as-errors); release builds on macOS and
  Linux.
- The build cache is keyed on the installed mapnik version.
Format: SwiftFormat 0.55.5 has no swiftformat_linux.zip asset (and the
archive contains a bare executable, not a directory), so the install step
failed. Use 0.64.5 and install the extracted binary explicitly; the tree
lints clean with it.

Sanitizer: TSan needs to disable ASLR, which requires the personality
syscall that Docker's default seccomp profile blocks, so the job died with
'encountered an incompatible memory layout'. Run the container with
seccomp=unconfined and invoke the tests under setarch -R.
@trasch trasch self-assigned this Nov 2, 2026
@trasch trasch added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 2, 2026
@trasch
trasch merged commit 91d3b67 into main Nov 2, 2026
5 checks passed
@trasch
trasch deleted the docs-and-ci branch November 2, 2026 20:46
trasch added a commit that referenced this pull request Nov 2, 2026
Rebased onto main after #111-#116 landed. Conflicts were resolved by keeping
main's newer logic and re-applying this PR's hardening on top:
- MapnikPool keeps the unlocked-factory acquire from #112.
- TileSequence/MetatileSequence keep main's bounds.isGeographic check, now
  thrown as MapnikError.invalidInput instead of a precondition.

Trapping accessors
- layerVisible(_:), layerSRS(_:), layerQueryable(_:) and
  layerVisible(_:atScaleDenominator:) used a plain Int32(index), which
  traps for indices outside Int32 range. They now return nil as
  documented.
- Metatile.init, TileSequence.init and MetatileSequence.init used
  precondition for user-facing validation. They now throw
  MapnikError.invalidInput, so callers that build blocks or sequences from
  external data get an error instead of a crash.
- MetatileOptions.metatileSize/validate no longer trap on a huge
  width x scale.

Silent truncation
- srs and layerSRS grow the buffer instead of returning a silently
  truncated projection string; long PROJ.4 strings exceed 255 characters.

Validation
- ImageFormat validates its options (png colors 1...256, jpeg/webp quality
  0...100), so a bad value surfaces as MapnikError.invalidInput instead of
  a renderingFailed from deep inside mapnik.
- setBufferSize clamps negative values, matching RenderOptions.validate.

Errors
- MapnikError is Equatable and LocalizedError, and gained a
  serializationFailed case.
- MapnikPoolError.exhausted carries the pool limit and is Equatable.

BoundingBox parsing
- BoundingBox(parsing:) parses positionally and rejects non-finite values.
  It previously used compactMap, so "1,2,foo,3,4" was accepted as
  (1,2,3,4) with the bad field silently dropped.

Tests
- APIHardeningTests: huge layer indices, long SRS round trip, negative
  bufferSize, ImageFormat validation, error equality, Metatile/sequence
  validation instead of trapping, and malformed bounding-box strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment