Skip to content

DocC fixes #1942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Similar to `optional` reducers, another common pattern in applications is the us
``AnyReducer/forEach(state:action:environment:file:fileID:line:)-2ypoa`` to allow running a reducer
on each element of a collection. Converting such child and parent reducers will look nearly
identical to what we did above for optional reducers, but it will make use of the new
``ReducerProtocol/forEach(_:action:_:file:fileID:line:)`` operator instead.
``ReducerProtocol/forEach(_:action:element:file:fileID:line:)`` operator instead.

In particular, the new `forEach` method operates on the parent reducer by specifying the collection
sub-state you want to work on, and providing the element reducer you want to be able to run on
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deprecations

Review unsupported `Reduce` APIs.

## Topics

### Reducer structure

- ``Reduce/init(_:environment:)``
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ instead.
- ``AnyReducer``
- ``Reducer``
- ``DebugEnvironment``
- ``Identified``
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,5 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement

### WithViewStore

- ``WithViewStore/init(_:content:file:line:)-1gjbi``
- ``WithViewStore/init(_:content:file:line:)-2uj44``
- ``WithViewStore/init(_:content:file:line:)-5vj3w``
- ``WithViewStore/init(_:content:file:line:)-5zsmz``
- ``WithViewStore/init(_:content:file:line:)-7kai``
- ``WithViewStore/init(_:file:line:content:)-4xog0``
- ``WithViewStore/init(_:file:line:content:)-55smh``
- ``WithViewStore/init(_:file:line:content:)-7qkc1``
- ``WithViewStore/init(_:file:line:content:)-8b21b``
- ``WithViewStore/init(_:file:line:content:)-9b6e2``
- ``WithViewStore/init(_:removeDuplicates:content:file:line:)-1lyhl``
- ``WithViewStore/init(_:removeDuplicates:content:file:line:)-35xje``
- ``WithViewStore/init(_:removeDuplicates:content:file:line:)-8zzun``
- ``WithViewStore/init(_:removeDuplicates:content:file:line:)-9atby``
- ``WithViewStore/init(_:removeDuplicates:file:line:content:)``
- ``WithViewStore/Action``
- ``WithViewStore/State``

<!--DocC: Can't currently document `View` extensions-->
<!--### View Modifiers-->
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement
### Creating a test store

- ``TestStore/init(initialState:reducer:environment:file:line:)``
- ``TestStore/init(initialState:reducer:prepareDependencies:file:line:)-72tkt``

### Configuring a test store

Expand All @@ -20,8 +21,8 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement

- ``TestStore/send(_:assert:file:line:)-30pjj``
- ``TestStore/receive(_:assert:file:line:)-2nhm0``
- ``TestStore/receive(_:assert:file:line:)-6fuav``
- ``TestStore/receive(_:assert:file:line:)-u5tf``
- ``TestStore/receive(_:assert:file:line:)-1bfw4``
- ``TestStore/receive(_:assert:file:line:)-5o4u3``
- ``TestStore/assert(_:file:line:)-707lb``
- ``TestStore/assert(_:file:line:)-4gff7``
- ``TestStore/LocalState``
Expand All @@ -32,3 +33,8 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement

- ``TestStore/skipReceivedActions(strict:file:line:)-3nldt``
- ``TestStore/skipInFlightEffects(strict:file:line:)-95n5f``

### Scoping test stores

- ``TestStore/scope(state:action:)``
- ``TestStore/scope(state:)``
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement

### SwiftUI integration

- ``ViewStore/subscript(dynamicMember:)-7xjrv``
- ``ViewStore/subscript(dynamicMember:)-3q4xh``
- ``ViewStore/binding(keyPath:send:)``
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
- ``EffectPublisher/merge(_:)-45guh``
- ``EffectPublisher/merge(_:)-3d54p``

### Concurrency

- ``UncheckedSendable``

### Testing

- ``EffectPublisher/unimplemented(_:)``
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ``ComposableArchitecture/Reduce``

## Topics

### Creating a reducer

- ``init(_:)-17fld``

### Type erased reducers

- ``init(_:)-3rph8``

### Deprecations

- <doc:ReduceDeprecations>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- ``reduce(into:action:)-8yinq``
- ``State``
- ``Action``
- ``EffectPublisher``
- ``EffectTask``

### Reducer composition

Expand All @@ -17,21 +17,21 @@
- ``Scope``
- ``ifLet(_:action:then:file:fileID:line:)``
- ``ifCaseLet(_:action:then:file:fileID:line:)``
- ``forEach(_:action:_:file:fileID:line:)``
- ``forEach(_:action:element:file:fileID:line:)``

### Supporting reducers

- ``BindingReducer``
- ``Reduce``
- ``CombineReducers``
- ``EmptyReducer``
- ``Reduce``
- ``BindingReducer``

### Reducer modifiers

- ``dependency(_:_:)``
- ``transformDependency(_:transform:)``
- ``_printChanges(_:)``
- ``signpost(_:log:)``
- ``debug()``

### Deprecations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Creating a store

- ``init(initialState:reducer:)``
- ``init(initialState:reducer:prepareDependencies:)``
- ``StoreOf``

### Scoping stores
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ``ComposableArchitecture/TaskResult``

## Topics

### Representing a task result

- ``success(_:)``
- ``failure(_:)``

### Converting a throwing expression

- ``init(catching:)``

### Accessing a result's value

- ``value``

### Transforming results

- ``map(_:)``
- ``flatMap(_:)``
- ``init(_:)``
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

### Creating a test store

- ``init(initialState:reducer:prepareDependencies:file:line:)``
- ``init(initialState:reducer:prepareDependencies:file:line:)-55zkv``
- ``init(initialState:reducer:observe:prepareDependencies:file:line:)``
- ``init(initialState:reducer:observe:send:prepareDependencies:file:line:)``

### Configuring a test store

Expand All @@ -16,8 +18,8 @@

- ``send(_:assert:file:line:)-1ax61``
- ``receive(_:timeout:assert:file:line:)-1rwdd``
- ``receive(_:timeout:assert:file:line:)-4e4m0``
- ``receive(_:timeout:assert:file:line:)-3myco``
- ``receive(_:timeout:assert:file:line:)-8xkqt``
- ``receive(_:timeout:assert:file:line:)-2ju31``
- ``finish(timeout:file:line:)``
- ``TestStoreTask``

Expand All @@ -32,11 +34,6 @@ While the most common way of interacting with a test store's state is via its ``

- ``state``

### Scoping test stores

- ``scope(state:action:)``
- ``scope(state:)``

### Deprecations

- <doc:TestStoreDeprecations>
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public struct AnyReducer<State, Action, Environment> {

/// This API has been soft-deprecated in favor of
/// ``ReducerProtocol/ifCaseLet(_:action:then:file:fileID:line:)`` and
/// ``Scope/init(state:action:_:file:fileID:line:)``. Read <doc:MigratingToTheReducerProtocol>
/// ``Scope/init(state:action:child:file:fileID:line:)``. Read <doc:MigratingToTheReducerProtocol>
/// for more information.
///
/// Transforms a reducer that works on child state, action, and environment into one that works on
Expand Down Expand Up @@ -942,7 +942,7 @@ public struct AnyReducer<State, Action, Environment> {
}

/// This API has been soft-deprecated in favor of
/// ``ReducerProtocol/forEach(_:action:_:file:fileID:line:)``. Read
/// ``ReducerProtocol/forEach(_:action:element:file:fileID:line:)``. Read
/// <doc:MigratingToTheReducerProtocol> for more information.
///
/// A version of ``pullback(state:action:environment:)`` that transforms a reducer that works on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ extension ReducerProtocol {
///
/// - Parameter printer: A printer for printing debug messages.
/// - Returns: A reducer that prints debug messages for all received actions.
#if swift(>=5.8)
@_documentation(visibility: public)
#endif
@inlinable
public func _printChanges(
Comment on lines +9 to 13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying out the new documentation visibility attribute.

_ printer: _ReducerPrinter<State, Action>? = .customDump
Expand Down
18 changes: 12 additions & 6 deletions Sources/ComposableArchitecture/Reducer/Reducers/Scope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/// ```
///
/// A parent reducer with a domain that holds onto the child domain can use
/// ``init(state:action:_:)`` to embed the child reducer in its
/// ``init(state:action:child:)`` to embed the child reducer in its
/// ``ReducerProtocol/body-swift.property-7foai``:
///
/// ```swift
Expand Down Expand Up @@ -58,7 +58,7 @@
/// ## Enum state
///
/// The ``Scope`` reducer also works when state is modeled as an enum, not just a struct. In that
/// case you can use ``init(state:action:_:file:fileID:line:)`` to specify a case path that
/// case you can use ``init(state:action:child:file:fileID:line:)`` to specify a case path that
/// identifies the case of state you want to scope to.
///
/// For example, if your state was modeled as an enum for unloaded/loading/loaded, you could
Expand Down Expand Up @@ -96,7 +96,8 @@
/// For an alternative to using ``Scope`` with state case paths that enforces the order, check out
/// the ``ifCaseLet(_:action:then:file:fileID:line:)`` operator.
public struct Scope<ParentState, ParentAction, Child: ReducerProtocol>: ReducerProtocol {
public enum StatePath {
@usableFromInline
enum StatePath {
case casePath(
CasePath<ParentState, Child.State>,
file: StaticString,
Expand All @@ -106,9 +107,14 @@ public struct Scope<ParentState, ParentAction, Child: ReducerProtocol>: ReducerP
case keyPath(WritableKeyPath<ParentState, Child.State>)
}

public let toChildState: StatePath
public let toChildAction: CasePath<ParentAction, Child.Action>
public let child: Child
@usableFromInline
let toChildState: StatePath

@usableFromInline
let toChildAction: CasePath<ParentAction, Child.Action>

@usableFromInline
let child: Child

@usableFromInline
init(
Expand Down
8 changes: 4 additions & 4 deletions Sources/ComposableArchitecture/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ import Foundation
/// #### Thread safety checks
///
/// The store performs some basic thread safety checks in order to help catch mistakes. Stores
/// constructed via the initializer ``init(initialState:reducer:)`` are assumed to run
/// only on the main thread, and so a check is executed immediately to make sure that is the case.
/// Further, all actions sent to the store and all scopes (see ``scope(state:action:)``) of the
/// store are also checked to make sure that work is performed on the main thread.
/// constructed via the initializer ``init(initialState:reducer:prepareDependencies:)`` are assumed
/// to run only on the main thread, and so a check is executed immediately to make sure that is the
/// case. Further, all actions sent to the store and all scopes (see ``scope(state:action:)``) of
/// the store are also checked to make sure that work is performed on the main thread.
public final class Store<State, Action> {
private var bufferedActions: [Action] = []
@_spi(Internals) public var effectCancellables: [UUID: AnyCancellable] = [:]
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableArchitecture/SwiftUI/ForEachStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import SwiftUI
/// }
/// ```
///
/// Enhance its core reducer using ``ReducerProtocol/forEach(_:action:_:file:fileID:line:)``:
/// Enhance its core reducer using ``ReducerProtocol/forEach(_:action:element:file:fileID:line:)``:
///
/// ```swift
/// var body: some ReducerProtocol<State, Action> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableArchitecture/SwiftUI/SwitchStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import SwiftUI
/// ```
///
/// See ``ReducerProtocol/ifCaseLet(_:action:then:file:fileID:line:)`` and
/// ``Scope/init(state:action:_:file:fileID:line:)`` for embedding reducers that operate on each
/// ``Scope/init(state:action:child:file:fileID:line:)`` for embedding reducers that operate on each
/// case of an enum in reducers that operate on the entire enum.
public struct SwitchStore<State, Action, Content: View>: View {
public let store: Store<State, Action>
Expand Down
14 changes: 9 additions & 5 deletions Sources/ComposableArchitecture/TestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,9 @@ extension TestStore where ScopedState: Equatable {
let previousState = self.reducer.state
let task = self.store
.send(.init(origin: .send(self.fromScopedAction(action)), file: file, line: line))
await self.reducer.effectDidSubscribe.stream.first(where: { _ in true })
for await _ in self.reducer.effectDidSubscribe.stream {
break
}
Comment on lines -1046 to +1048
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated sendability fix.

do {
let currentState = self.state
self.reducer.state = previousState
Expand Down Expand Up @@ -1454,7 +1456,7 @@ extension TestStore where ScopedState: Equatable, Action: Equatable {
extension TestStore where ScopedState: Equatable {
/// Asserts a matching action was received from an effect and asserts how the state changes.
///
/// See ``receive(_:timeout:assert:file:line:)-3myco`` for more information of how to use this
/// See ``receive(_:timeout:assert:file:line:)-2ju31`` for more information of how to use this
/// method.
///
/// - Parameters:
Expand Down Expand Up @@ -1491,7 +1493,7 @@ extension TestStore where ScopedState: Equatable {

/// Asserts an action was received matching a case path and asserts how the state changes.
///
/// See ``receive(_:timeout:assert:file:line:)-4e4m0`` for more information of how to use this
/// See ``receive(_:timeout:assert:file:line:)-8xkqt`` for more information of how to use this
/// method.
///
/// - Parameters:
Expand Down Expand Up @@ -1601,7 +1603,7 @@ extension TestStore where ScopedState: Equatable {
/// was in the effect that you chose not to assert on.
///
/// If you only want to check that a particular action case was received, then you might find the
/// ``receive(_:timeout:assert:file:line:)-4e4m0`` overload of this method more useful.
/// ``receive(_:timeout:assert:file:line:)-8xkqt`` overload of this method more useful.
///
/// - Parameters:
/// - isMatching: A closure that attempts to match an action. If it returns `false`, a test
Expand Down Expand Up @@ -2402,7 +2404,9 @@ public enum Exhaustivity: Equatable {
/// ``TestStore/skipInFlightEffects(strict:file:line:)-5hbsk``.
///
/// To partially match an action received from an effect, use
/// ``TestStore/receive(_:timeout:assert:file:line:)-4e4m0``.
/// ``TestStore/receive(_:timeout:assert:file:line:)-8xkqt`` or
/// ``TestStore/receive(_:timeout:assert:file:line:)-2ju31``.

case on

/// Non-exhaustive assertions.
Expand Down