File tree Expand file tree Collapse file tree 7 files changed +40
-18
lines changed
Extensions/InheritedTypeSyntax Expand file tree Collapse file tree 7 files changed +40
-18
lines changed Original file line number Diff line number Diff line change 16
16
/// public final class DependencyMock: Dependency { ... }
17
17
/// ```
18
18
///
19
- /// - Parameter compilationCondition: The compilation condition to apply to the
20
- /// `#if` compiler directive used to wrap the generated mock.
21
- // TODO: Docs
19
+ /// - Parameters:
20
+ /// - compilationCondition: The compilation condition to apply to the
21
+ /// `#if` compiler directive used to wrap the generated mock.
22
+ /// (default: `.swiftMockingEnabled`)
23
+ /// - sendableConformance: The `Sendable` conformance to apply to
24
+ /// the generated mock. (default: `.checked`)
22
25
@attached ( peer, names: suffixed ( Mock) )
23
26
public macro Mocked(
24
27
compilationCondition: MockCompilationCondition = . swiftMockingEnabled,
Original file line number Diff line number Diff line change 4
4
// Copyright © 2025 Fetch.
5
5
//
6
6
7
- // TODO: Docs
7
+ /// A `Sendable` conformance that can be applied to a mock declaration.
8
8
public enum MockSendableConformance {
9
9
10
- // TODO: Docs
10
+ /// The mock adheres to the `Sendable` conformance of the original
11
+ /// implementation.
11
12
case checked
12
13
13
- // TODO: Docs
14
+ /// The mock conforms to `@unchecked Sendable`.
14
15
case unchecked
15
16
}
Original file line number Diff line number Diff line change @@ -8,8 +8,13 @@ import SwiftSyntax
8
8
9
9
extension InheritedTypeSyntax {
10
10
11
- // TODO: Docs
12
- // @unchecked Sendable
11
+ /// An `InheritedTypeSyntax` representing unchecked sendable conformance
12
+ /// with a trailing comma.
13
+ ///
14
+ /// ```swift
15
+ /// // Represents
16
+ /// @unchecked Sendable,
17
+ /// ```
13
18
static let uncheckedSendable = InheritedTypeSyntax (
14
19
type: AttributedTypeSyntax (
15
20
specifiers: [ ] ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ extension MockedMacro {
19
19
/// The compilation condition with which to wrap the generated mock.
20
20
let compilationCondition : MockCompilationCondition
21
21
22
- // TODO: Docs
22
+ /// The sendable conformance to apply to the generated mock.
23
23
let sendableConformance : MockSendableConformance
24
24
25
25
// MARK: Initializers
Original file line number Diff line number Diff line change @@ -178,10 +178,13 @@ extension MockedMacro {
178
178
/// final class DependencyMock: Dependency {}
179
179
/// ```
180
180
///
181
- /// - Parameter protocolDeclaration: The protocol to which the mock must
182
- /// conform.
181
+ /// - Parameters:
182
+ /// - protocolDeclaration: The protocol to which the mock must
183
+ /// conform.
184
+ /// - sendableConformance: The sendable conformance the mock should have.
185
+ /// If `.unchecked`, the clause will include `@unchecked Sendable`.
186
+ ///
183
187
/// - Returns: The inheritance clause to apply to the mock declaration.
184
- // TODO: Docs
185
188
private static func mockInheritanceClause(
186
189
from protocolDeclaration: ProtocolDeclSyntax ,
187
190
sendableConformance: MockSendableConformance
Original file line number Diff line number Diff line change 6
6
7
7
import SwiftSyntax
8
8
9
- // TODO: Docs
9
+ /// A protocol for arguments that can be parsed from a macro's argument
10
+ /// syntax.
10
11
protocol MacroArgument {
12
+
13
+ /// Creates a macro argument from the provided `argument`.
14
+ ///
15
+ /// - Parameter argument: The argument syntax from which to parse the
16
+ /// macro argument.
11
17
init ? ( argument: LabeledExprSyntax )
12
18
}
Original file line number Diff line number Diff line change 6
6
7
7
import SwiftSyntax
8
8
9
- // TODO: Docs
9
+ /// A `Sendable` conformance that can be applied to a mock declaration.
10
10
enum MockSendableConformance : String , MacroArgument {
11
11
12
- // TODO: Docs
12
+ /// The mock adheres to the `Sendable` conformance of the original
13
+ /// implementation.
13
14
case checked
14
15
15
- // TODO: Docs
16
+ /// The mock conforms to `@unchecked Sendable`.
16
17
case unchecked
17
-
18
- // TODO: Docs
18
+
19
+ /// Creates a sendable conformance from the provided `argument`.
20
+ ///
21
+ /// - Parameter argument: The argument syntax from which to parse a
22
+ /// sendable conformance.
19
23
init ? ( argument: LabeledExprSyntax ) {
20
24
guard
21
25
let memberAccessExpression = argument. expression. as (
You can’t perform that action at this time.
0 commit comments