0.1.1
Compile-time-validated descriptions for Swift enums, structs, classes, and actors.
.package(url: "https://github.com/WendellXY/Description.git", from: "0.1.1")@Describable
enum RequestState {
case idle
@Description("Loading {url}")
case loading(url: URL)
}
@Describable("HTTPError(code: {code})", error: "The request failed with HTTP {code}.")
struct HTTPError: Error {
let code: Int
}Features
@DescribablesynthesizesCustomStringConvertiblefor enums, structs, classes, and actors. It also synthesizesLocalizedErrorwhen the type listsErrorin its inheritance clause.@Descriptionconfigures individual enum cases. Cases without one are described by their name.- Templates support
{name},{0}, and{{/}}. Placeholders are validated during macro expansion. - Diagnostics point inside the template. Fix-its correct misspelled fields, escape stray braces, insert a memberwise template, and add
Errorconformance. - Actor descriptions are
nonisolated, and actor-isolated state is rejected at compile time. - Existing
description,errorDescription, and conformances are reported instead of overridden.
Changes since 0.1.0
- Added the MIT license.
- Added GitHub Actions CI, which runs the test suite on macOS and on Linux with Swift 6.0, 6.1, and 6.2.
- Made the test suite compatible with Swift 6.0.
- Documented a Foundation crash on Linux before Swift 6.2:
localizedDescriptioncrashes on any class-basedError, with or without@Describable. ReaderrorDescriptiondirectly, or use a struct or enum error.
No changes to the macros or their generated code.
Requirements: Swift 6.0 or later, and swift-syntax 600 through 604.