Skip to content

Commit c9e74ad

Browse files
authored
Add more availability annotations for image attachment symbols. (#1409)
Adds more of these: ```swift /// @metadata { /// @available(Swift, introduced: 6.3) /// } ``` To public symbols that DocC can see. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 564e4f2 commit c9e74ad

File tree

7 files changed

+46
-0
lines changed

7 files changed

+46
-0
lines changed

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if SWT_TARGET_OS_APPLE && canImport(CoreGraphics)
1212
public import UniformTypeIdentifiers
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
@available(_uttypesAPI, *)
1518
extension AttachableImageFormat {
1619
/// The content type corresponding to this image format.

Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ private import CoreGraphics
1313

1414
private import UniformTypeIdentifiers
1515

16+
/// @Metadata {
17+
/// @Available(Swift, introduced: 6.3)
18+
/// }
1619
@available(_uttypesAPI, *)
1720
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsImage {
1821
/// Get the image format to use when encoding an image, substituting a
@@ -47,11 +50,17 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At
4750
return encodingQuality < 1.0 ? .jpeg : .png
4851
}
4952

53+
/// @Metadata {
54+
/// @Available(Swift, introduced: 6.3)
55+
/// }
5056
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
5157
let imageFormat = _imageFormat(forPreferredName: attachment.preferredName)
5258
return try wrappedValue.withUnsafeBytes(as: imageFormat, body)
5359
}
5460

61+
/// @Metadata {
62+
/// @Available(Swift, introduced: 6.3)
63+
/// }
5564
public borrowing func preferredName(for attachment: borrowing Attachment<_AttachableImageWrapper>, basedOn suggestedName: String) -> String {
5665
let imageFormat = _imageFormat(forPreferredName: suggestedName)
5766
return (suggestedName as NSString).appendingPathExtension(for: imageFormat.contentType)

Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if os(Windows)
1212
public import WinSDK
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
extension AttachableImageFormat {
1518
private static let _encoderPathExtensionsByCLSID = Result {
1619
var result = [CLSID.Wrapper: [String]]()

Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if os(Windows)
1212
private import WinSDK
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsImage {
1518
/// Get the image format to use when encoding an image.
1619
///
@@ -38,11 +41,17 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At
3841
return encodingQuality < 1.0 ? .jpeg : .png
3942
}
4043

44+
/// @Metadata {
45+
/// @Available(Swift, introduced: 6.3)
46+
/// }
4147
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
4248
let imageFormat = _imageFormat(forPreferredName: attachment.preferredName)
4349
return try wrappedValue.withUnsafeBytes(as: imageFormat, body)
4450
}
4551

52+
/// @Metadata {
53+
/// @Available(Swift, introduced: 6.3)
54+
/// }
4655
public borrowing func preferredName(for attachment: borrowing Attachment<_AttachableImageWrapper>, basedOn suggestedName: String) -> String {
4756
let imageFormat = _imageFormat(forPreferredName: suggestedName)
4857
return AttachableImageFormat.appendPathExtension(for: imageFormat.encoderCLSID, to: suggestedName)

Sources/Testing/Attachments/Images/AttachableAsImage.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public protocol AttachableAsImage {
8181
/// The testing library uses this function when saving an image as an
8282
/// attachment. The implementation should use `imageFormat` to determine what
8383
/// encoder to use.
84+
///
85+
/// @Metadata {
86+
/// @Available(Swift, introduced: 6.3)
87+
/// }
8488
borrowing func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R
8589

8690
/// Make a copy of this instance to pass to an attachment.

Sources/Testing/Attachments/Images/AttachableImageFormat.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public struct AttachableImageFormat: Sendable {
7979

8080
// MARK: - Equatable, Hashable
8181

82+
/// @Metadata {
83+
/// @Available(Swift, introduced: 6.3)
84+
/// }
8285
#if SWT_NO_IMAGE_ATTACHMENTS
8386
@_unavailableInEmbedded
8487
@available(*, unavailable, message: "Image attachments are not available on this platform.")
@@ -120,12 +123,18 @@ extension AttachableImageFormat.Kind: Equatable, Hashable {
120123

121124
// MARK: - CustomStringConvertible, CustomDebugStringConvertible
122125

126+
/// @Metadata {
127+
/// @Available(Swift, introduced: 6.3)
128+
/// }
123129
#if SWT_NO_IMAGE_ATTACHMENTS
124130
@_unavailableInEmbedded
125131
@available(*, unavailable, message: "Image attachments are not available on this platform.")
126132
#endif
127133
@available(_uttypesAPI, *)
128134
extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConvertible {
135+
/// @Metadata {
136+
/// @Available(Swift, introduced: 6.3)
137+
/// }
129138
public var description: String {
130139
let kindDescription = String(describing: kind)
131140
if encodingQuality < 1.0 {
@@ -134,6 +143,9 @@ extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConve
134143
return kindDescription
135144
}
136145

146+
/// @Metadata {
147+
/// @Available(Swift, introduced: 6.3)
148+
/// }
137149
public var debugDescription: String {
138150
let kindDescription = String(reflecting: kind)
139151
return "\(kindDescription) at quality \(encodingQuality)"
@@ -142,6 +154,9 @@ extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConve
142154

143155
// MARK: -
144156

157+
/// @Metadata {
158+
/// @Available(Swift, introduced: 6.3)
159+
/// }
145160
#if SWT_NO_IMAGE_ATTACHMENTS
146161
@_unavailableInEmbedded
147162
@available(*, unavailable, message: "Image attachments are not available on this platform.")

Sources/Testing/Attachments/Images/Attachment+AttachableAsImage.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11+
/// @Metadata {
12+
/// @Available(Swift, introduced: 6.3)
13+
/// }
1114
#if SWT_NO_IMAGE_ATTACHMENTS
1215
@_unavailableInEmbedded
1316
@available(*, unavailable, message: "Image attachments are not available on this platform.")

0 commit comments

Comments
 (0)