Skip to content

feat(swift): generate CONTRIBUTING.md for Swift SDKs#15648

Merged
Swimburger merged 2 commits intomainfrom
devin/1777665236-swift-contributing-md
May 5, 2026
Merged

feat(swift): generate CONTRIBUTING.md for Swift SDKs#15648
Swimburger merged 2 commits intomainfrom
devin/1777665236-swift-contributing-md

Conversation

@Swimburger
Copy link
Copy Markdown
Member

@Swimburger Swimburger commented May 1, 2026

Description

Generate a Swift-specific CONTRIBUTING.md for Swift SDKs, using a new RootAsIsFiles pattern that extends the existing AsIs infrastructure for root-level files.

Changes Made

  • Extended generators/swift/base/src/AsIs.ts with a RootAsIsFiles registry for root-level static files (no symbols needed, just filename + content loading)
  • Added static generators/swift/base/src/asIs/Root/CONTRIBUTING.md with Swift-specific content:
    • Prerequisites: Swift 5.9+, Swift Package Manager
    • Install: swift package resolve
    • Build: swift build
    • Test: swift test
    • Format: swift format . / swiftformat .
    • Lint: swiftlint
    • References generators/swift/ as the generator path
    • Same overall structure as C# (Getting Started, About Generated Code with .fernignore, Making Changes, Questions, License)
  • Wired up in generators/swift/sdk/src/SdkGeneratorCli.ts:
    • Added generateRootAsIsFiles method that loads and adds root AsIs files
    • Called from generateRootFiles() in parallel with README/reference generation, gated behind !context.config.whitelabel
    • Imports RootAsIsFiles from @fern-api/swift-base
  • Added unit tests in generators/swift/sdk/src/__test__/ContributingGenerator.test.ts:
    • Tests for Swift commands, all sections, Fern info, generator path, prerequisites, filename, and a snapshot test (7 tests)
  • Added changelog entry in generators/swift/sdk/changes/unreleased/add-contributing-md.yml

Testing

  • Unit tests added/updated (7 tests, all passing)
  • Biome check passes on all changed files
  • pnpm format passes

Link to Devin session: https://app.devin.ai/sessions/e318dce18bb44560bd5859fb0d171213
Requested by: @Swimburger


Open in Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-04-23T04:59:11Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
swift-sdk square 41s (n=5) 290s (n=5) 45s +4s (+9.8%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-04-23T04:59:11Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-05-04 20:54 UTC

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Self-review: LGTM — No issues found. CI passing, code follows existing Swift generator patterns correctly. Generator path generators/swift/ is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no AsIs pattern to do this with copy/paste file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AsIs pattern in Swift (SourceAsIsFiles/addSourceAsIsFile) is designed for .swift source files that get compiled into the module — they include symbol registration with the NameRegistry and are placed under Sources/. CONTRIBUTING.md is a root-level markdown file, so it follows the same addRootFiles(new File(...)) pattern used by README.md, reference.md, and Package.swift.

This also matches how C# and TypeScript handle it — both use a ContributingGenerator class with addRawFiles/addRootFiles rather than an AsIs file.

That said, if you'd prefer a different approach (e.g. a static .md file that gets copied), happy to refactor.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin it shouldn't be difficult to extend this to allow root AsIs I think. We could just add RootAsIsFiles to AsIs.ts and then generate them in SdkGeneratorCLI generateRootFiles()? Could we not do that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — refactored to use the AsIs pattern. I've:

  1. Added RootAsIsFiles to generators/swift/base/src/AsIs.ts — a simpler variant of the existing AsIs registry (just filename + loadContents, no symbols/directory needed for root files)
  2. Placed the static CONTRIBUTING.md at generators/swift/base/src/asIs/Root/CONTRIBUTING.md
  3. Updated SdkGeneratorCli.ts to load via RootAsIsFiles.Contributing.loadContents() in generateRootAsIsFiles(), called in parallel with README/reference generation
  4. Removed the ContributingGenerator class entirely

This makes it easy to add more root AsIs files in the future — just add an entry to RootAsIsFileSpecs and drop the file in asIs/Root/.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Swimburger Swimburger merged commit 8b0c3e1 into main May 5, 2026
73 checks passed
@Swimburger Swimburger deleted the devin/1777665236-swift-contributing-md branch May 5, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants