Skip to content

Commit db38b20

Browse files
committed
Update docs
1 parent 2f6dfb1 commit db38b20

File tree

11 files changed

+40
-65
lines changed

11 files changed

+40
-65
lines changed

Sources/MockingKit/AsyncMockReference.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import Foundation
1010

1111
/// This type can be used to create mock function references.
12-
///
13-
/// Function references get unique IDs, which means that the
14-
/// mock reference instance can be uniquely identified.
1512
public struct AsyncMockReference<Arguments, Result>: Identifiable {
1613

1714
public init(_ function: @escaping (Arguments) async throws -> Result) {

Sources/MockingKit/Internals/Escaping.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// Original implementation: https://github.com/devxoul/Stubber
66
//
77

8-
/// These functions are used by mock calls where one or many
9-
/// arguments are escaping blocks.
8+
/// These functions are used by mock calls where one or many args are escaping.
109

1110
import Foundation
1211

Sources/MockingKit/Mock.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88

99
import Foundation
1010

11-
/// This class can be inherited when you want to create mock
12-
/// classes that don't have to inherit any other classes.
11+
/// This class can be used to create mock classes without inheritance.
1312
///
14-
/// The class implements ``Mockable`` by returning `self` as
15-
/// the ``mock`` property.
16-
///
17-
/// Inherit this type instead of implementing the ``Mockable``
18-
/// protocol, to save some code for every mock you create.
13+
/// The class implements ``Mockable`` and returns `self` as the ``mock``,
14+
/// to let you write less code for every mock you create.
1915
open class Mock: Mockable, @unchecked Sendable {
2016

2117
public init() {}

Sources/MockingKit/MockCall.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import Foundation
1010

11-
/// This struct represents function calls, with the provided
12-
/// ``arguments`` and the returned ``result``.
11+
/// This struct represents a mocked function calls.
1312
///
1413
/// Function that don't return anything have a `Void` result.
1514
public struct MockCall<Arguments, Result>: AnyCall {

Sources/MockingKit/MockReference.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import Foundation
1010

1111
/// This type can be used to create mock function references.
12-
///
13-
/// Function references get unique IDs, which means that the
14-
/// mock reference instance can be uniquely identified.
1512
public struct MockReference<Arguments, Result>: Identifiable {
1613

1714
public init(_ function: @escaping (Arguments) throws -> Result) {

Sources/MockingKit/Mockable+Call.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public extension Mockable {
1212

1313
/// Call a mock reference with a `non-optional` result.
1414
///
15-
/// This will return any pre-registered result, or crash
16-
/// if no result has been registered.
15+
/// This will return any pre-registered result, or crash if no result is registered.
1716
///
1817
/// - Parameters:
1918
/// - ref: The mock reference to call.
@@ -43,8 +42,7 @@ public extension Mockable {
4342

4443
/// Call a mock reference with a `non-optional` result.
4544
///
46-
/// This will return any pre-registered result, or crash
47-
/// if no result has been registered.
45+
/// This will return any pre-registered result, or crash if no result is registered.
4846
///
4947
/// - Parameters:
5048
/// - ref: The mock reference to call.
@@ -74,8 +72,7 @@ public extension Mockable {
7472

7573
/// Call a mock reference with a `non-optional` result.
7674
///
77-
/// This will return any pre-registered result or return
78-
/// a `fallback` value if no result has been registered.
75+
/// This will return any pre-registered result, else the provided `fallback`.
7976
///
8077
/// - Parameters:
8178
/// - ref: The mock reference to call.
@@ -93,8 +90,7 @@ public extension Mockable {
9390

9491
/// Call a mock reference with a `non-optional` result.
9592
///
96-
/// This will return any pre-registered result or return
97-
/// a `fallback` value if no result has been registered.
93+
/// This will return any pre-registered result, else the provided `fallback`.
9894
///
9995
/// - Parameters:
10096
/// - ref: The mock reference to call.
@@ -112,8 +108,7 @@ public extension Mockable {
112108

113109
/// Call a mock reference with an `optional` result.
114110
///
115-
/// This will return a pre-registered result or `nil` if
116-
/// no result has been registered.
111+
/// This will return any pre-registered result, else `nil`.
117112
///
118113
/// - Parameters:
119114
/// - ref: The mock reference to call.
@@ -129,8 +124,7 @@ public extension Mockable {
129124

130125
/// Call a mock reference with an `optional` result.
131126
///
132-
/// This will return a pre-registered result or `nil` if
133-
/// no result has been registered.
127+
/// This will return any pre-registered result, else `nil`.
134128
///
135129
/// - Parameters:
136130
/// - ref: The mock reference to call.

Sources/MockingKit/Mockable+Inspect.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ public extension Mockable {
9292

9393
/// Check if a mock reference has been called.
9494
///
95-
/// For this function to return `true` the actual number
96-
/// of calls must match the provided `numberOfCalls`.
95+
/// For this to return `true` the number of calls must match `numberOfCalls`.
9796
///
9897
/// - Parameters:
9998
/// - ref: The mock reference to check calls for.
@@ -107,8 +106,7 @@ public extension Mockable {
107106

108107
/// Check if a mock reference has been called.
109108
///
110-
/// For this function to return `true` the actual number
111-
/// of calls must match the provided `numberOfCalls`.
109+
/// For this to return `true` the number of calls must match `numberOfCalls`.
112110
///
113111
/// - Parameters:
114112
/// - refKeyPath: A key path to the mock reference to check calls for.
@@ -122,8 +120,7 @@ public extension Mockable {
122120

123121
/// Check if an async mock reference has been called.
124122
///
125-
/// For this function to return `true` the actual number
126-
/// of calls must match the provided `numberOfCalls`.
123+
/// For this to return `true` the number of calls must match `numberOfCalls`.
127124
///
128125
/// - Parameters:
129126
/// - ref: The mock reference to check calls for.
@@ -136,8 +133,7 @@ public extension Mockable {
136133

137134
/// Check if an async mock reference has been called.
138135
///
139-
/// For this function to return `true` the actual number
140-
/// of calls must match the provided `numberOfCalls`.
136+
/// For this to return `true` the number of calls must match `numberOfCalls`.
141137
///
142138
/// - Parameters:
143139
/// - refKeyPath: A key path to the mock reference to check calls for.

Sources/MockingKit/Mockable+Register.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Foundation
1111
public extension Mockable {
1212

1313
/// Register a result value for a mock reference.
14+
///
1415
/// - Parameters:
1516
/// - ref: The mock reference to register a result for.
1617
/// - result: What to return when the function is called.
@@ -22,6 +23,7 @@ public extension Mockable {
2223
}
2324

2425
/// Register a result value for a mock reference.
26+
///
2527
/// - Parameters:
2628
/// - refKeyPath: A key path to the mock reference to register a result for.
2729
/// - result: What to return when the function is called.
@@ -33,6 +35,7 @@ public extension Mockable {
3335
}
3436

3537
/// Register a result value for an async mock reference.
38+
///
3639
/// - Parameters:
3740
/// - ref: The mock reference to register a result for.
3841
/// - result: What to return when the function is called.
@@ -44,6 +47,7 @@ public extension Mockable {
4447
}
4548

4649
/// Register a result value for an async mock reference.
50+
///
4751
/// - Parameters:
4852
/// - refKeyPath: A key path to the mock reference to register a result for.
4953
/// - result: What to return when the function is called.

Sources/MockingKit/Mockable.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
import Foundation
1010

11-
/// This class can be inherited when you want to create mock
12-
/// classes that have to inherit other classes.
11+
/// This protocol can be implemented to create custom mock types.
1312
///
14-
/// To implement this protocol, just inherit your base class
15-
/// and provide a ``mock`` property:
13+
/// To implement this protocol, just implement the protocol or inherit the class that
14+
/// you want to mock, then provide a ``mock`` property:
1615
///
1716
/// ```
1817
/// class MyMock: BaseClass, Mockable {
1918
/// let mock = Mock()
2019
/// }
2120
/// ```
2221
///
23-
/// Implement this protocol instead of inheriting the ``Mock``
24-
/// base class, to save some code for every mock you create.
22+
/// You can inherit the ``Mock`` base class to automatically set up a ``mock``,
23+
/// if your mock doesn't have to inherit another type.
2524
public protocol Mockable: Sendable {
2625

2726
typealias Function = Any

Sources/MockingKit/Mocks/MockNotificationCenter.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ open class MockNotificationCenter: NotificationCenter, Mockable, @unchecked Send
4848
}
4949
}
5050

51-
/**
52-
These functions provide more explicit names, which makes it
53-
easier to create the refs without having to use typealiases.
54-
*/
51+
/// These functions provide more explicit names, which makes it easier to create
52+
/// the mock function refs without having to use typealiases.
5553
private extension MockNotificationCenter {
5654

5755
func mockAddObserverForName(_ name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Void) -> NSObjectProtocol {

0 commit comments

Comments
 (0)