Skip to content

Releases: theoriginalbit/SwiftStructureKit

Documentation catalog

Choose a tag to compare

@theoriginalbit theoriginalbit released this 21 Oct 11:28

Added a DocC documentation archive.

Expressions, Extensions, and a Better Renderer

Choose a tag to compare

@theoriginalbit theoriginalbit released this 21 Oct 09:45

Note

The package now requires Swift tools version 6.1 to be available.

New source-generation capabilities

  • Describe extensions, including added conformances, generic where requirements, members, and default access levels.
  • Represent new expressions; tuple, member-access, function calls, and if/else if/else expressions.
  • Render try, await, throw, break, and continue statements.
  • Add generic parameters to typealiases.

Tweaks

  • Initialisers and conveniences for guard, if, and return that were erroneously internal have now been made public.

More correct and consistent output

  • Render special Double values such as infinity and NaN as valid Swift expressions.
  • Sanitise identifiers according to their syntactic position, improving output for keywords and other special identifiers.
  • Improve whitespace and punctuation handling, including compacting empty blocks, and fix protocol subscript rendering.
  • Remove duplicate generic parameters, conformances, type constraints, type-alias composition types, and attributes while preserving their first occurrence.
  • Rendering hot paths are now more efficient.

Migration notes

  • The dependency on swift-collections has been removed1.
    • Public collection APIs that used OrderedSet now use arrays; duplicate entries are still omitted from rendered output.
  • TypeMemberDescriptor and TypeMembersBuilder are replaced by DeclarationDescriptor and DeclarationBuilder.
  • SwiftFile.declarations now uses TopLevelDeclarationDescriptor so it can include extensions which are only valid at the file scope; update code that explicitly constructs or switches over these values.
  • Replace .stored(isMutable: true, ...) / .stored(isMutable: false, ...) with .stored(.var, ...) / .stored(.let, ...).
  • Replace ProtocolAssociatedtypeDescriptor(..., sameTypeAs: ...) with defaultType: for associated-type defaults.
  • AccessModifierDescriptor.open was removed until class descriptors are added.

  1. Generic parameters, conformances, and type compositions have changed from OrderedSet to Array. ↩

Declarative Swift Source Generation

Choose a tag to compare

@theoriginalbit theoriginalbit released this 16 Oct 06:24

The first stable release of SwiftStructureKit, a lightweight library for building and rendering Swift source code with a declarative API.

Features

  • Build Swift files containing imports, structs, protocols, enums, functions, properties, and type aliases.
  • Describe statements, types, attributes, comments, and diagnostic directives.
  • Render generated source directly to a file or to Data.
  • Choose spaces or tabs for indentation.