Skip to content

docs: every README example compiles, and CI keeps it that way - #219

Merged
SteliyanH merged 1 commit into
developfrom
docs/readme-snippets
Nov 15, 2026
Merged

SteliyanH merged 1 commit into
developfrom
docs/readme-snippets

Conversation

@SteliyanH

Copy link
Copy Markdown
Owner

Four README examples did not compile. They now do, and CI compiles every Swift block in the README from here on.

Fixed in the README

  • Ken Burns example: Transform(scale:center:) → Transform(center:scale:). The initialiser takes center first.
  • Slow-mo example: .speed(0.5) → .speed(.flat(0.5)).
  • Before/after table: Video { urls.map { VideoClip(url: $0) } } → Video { for url in urls { VideoClip(url: url) } }.
  • Compositor example: used MultiplyBlend() without defining it. The block now defines it, using the code from the MultiInputCompositor doc comment.
  • Examples section: was one block that declared let url eight times, so it could not compile as written. It is now one block per recipe, each with a heading.

How it stays fixed

  • Tools/readme-snippets.sh copies each ```swift block into Examples/ReadmeSnippets.swift, one function per block. `swift test` already builds the `Examples` target, so a broken example fails the build.
  • A new CI step, Tools/readme-snippets.sh --check, fails if that file is out of date.
  • Blocks that aren't compilable Swift (the Package.swift snippet) opt out with <!-- readme-snippets: skip -->.
  • Placeholder URLs and images live in Examples/ReadmeSnippetAssets.swift. That file also checks the before/after table by hand, because the table is inline code.

Verified

  • Generating from the old README reproduced all four errors.
  • Putting .speed(0.5) back is caught twice: the drift check flags the stale file, and the build fails after regenerating.
  • A deliberate error in Examples/ fails swift build --build-tests, which confirms CI compiles the target.
  • swift build --target KadrExamples is clean, with no warnings from the new files.

No library code changes.

Four README snippets did not compile: Transform's arguments out of order,
.speed(0.5) instead of .speed(.flat(0.5)), an array mapped inside Video {},
and an undefined MultiplyBlend. Tools/readme-snippets.sh copies each Swift
block into Examples/ReadmeSnippets.swift so the Examples target compiles it;
CI fails if that copy is stale.
@SteliyanH
SteliyanH merged commit 59dcf4f into develop Nov 15, 2026
2 checks passed
@SteliyanH
SteliyanH deleted the docs/readme-snippets branch November 15, 2026 06:41
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant