Skip to content

Releases: coenttb/swift-splat

0.2.0 - Comprehensive DocC Documentation Mirroring

07 Nov 11:28

Choose a tag to compare

Documentation Mirroring for Generated Initializers

The @Splat macro now extracts and mirrors documentation from the Arguments struct to generated initializers.

Changes

Documentation Extraction

The macro traverses the Arguments struct to extract:

  • Summary and discussion from Arguments init
  • Parameter descriptions from Arguments init (not property docs)
  • Throws documentation from parent init
  • DocC formatting preservation (blank lines, code blocks, callouts)

Generated Output

Generated initializers include:

  • Complete DocC summary section
  • Discussion section with context
  • Parameter documentation for each argument
  • Throws clause with error conditions
  • Proper DocC formatting conventions

Example

Before 0.2.0:

@Splat
struct Person: Sendable {
    let arguments: Arguments
    // Generated init: no documentation
    
    struct Arguments: Sendable {
        /// The person's full name
        let name: String
    }
}

With 0.2.0:

@Splat
struct Person: Sendable {
    let arguments: Arguments
    // Generated init: includes all documentation from Arguments init
    
    struct Arguments: Sendable {
        /// The person's full name
        let name: String
        
        /// Creates person arguments.
        /// - Parameter name: Full legal name
        init(name: String) { self.name = name }
    }
}

Technical Details

Implementation:

  • Parses trivia from Arguments struct members
  • Extracts documentation from init declaration
  • Handles DocC sections (summary, discussion, parameters, throws)
  • Preserves formatting with proper indentation
  • Uses PropertyInfo struct to avoid large tuple warnings
  • Applies SwiftLint compliance (for-where, cyclomatic complexity)

Upgrading

Update Package.swift:

.package(url: "https://github.com/coenttb/swift-splat", from: "0.2.0")

No code changes required. Existing @Splat usage benefits from documentation generation.

Full Changelog: 0.1.0...0.2.0

0.1.0

07 Nov 10:54

Choose a tag to compare

@Splat Macro for Swift 6.2

Swift macro that generates parameter-based initializers from a nested Arguments struct.

Features

  • Automatic initializer generation from Arguments struct
  • Support for throws and typed throws(ErrorType)
  • Natural language property names with backticks (Swift 6.2+)
  • Optional types with Bool? support
  • Customizable property and struct names via macro arguments
  • Swift 6 strict concurrency support

Example

@Splat
struct Person: Sendable {
    let arguments: Arguments
    
    init(_ arguments: Arguments) {
        self.arguments = arguments
    }
    
    struct Arguments: Sendable {
        let name: String
        let age: Int
    }
}

// Generated initializer:
let person = Person(name: "Alice", age: 30)

Requirements

  • Swift 6.2+
  • macOS 15+ / iOS 18+

Installation

Add to Package.swift:

dependencies: [
    .package(url: "https://github.com/coenttb/swift-splat", from: "0.1.0")
]

Documentation

See README.md for complete documentation and examples.