Skip to content

Commit ff8fa94

Browse files
committed
Update some underscore public API doc
1 parent 25e716d commit ff8fa94

File tree

14 files changed

+79
-0
lines changed

14 files changed

+79
-0
lines changed

Sources/OpenSwiftUI/Core/Graph/Graph.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
// Audited for RELEASE_2021
66
// Status: Complete
77

8+
/// A transient reference to a view graph.
89
public struct _Graph {}

Sources/OpenSwiftUI/Core/Graph/GraphInputsModifier.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Audited for RELEASE_2021
66
// Status: Complete
77

8+
/// Protocol for modifiers that only modify their children's inputs.
89
public protocol _GraphInputsModifier {
910
static func _makeInputs(modifier: _GraphValue<Self>, inputs: inout _GraphInputs)
1011
}

Sources/OpenSwiftUI/Core/Graph/GraphValue.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
internal import OpenGraphShims
99

10+
/// A transient reference to a value in the view hierarchy's dataflow
11+
/// graph. "Transient" means that these values must never be stored,
12+
/// only passed around while initializing views.
1013
public struct _GraphValue<Value>: Equatable {
1114
var value: Attribute<Value>
1215

@@ -26,6 +29,8 @@ public struct _GraphValue<Value>: Equatable {
2629
_GraphValue<V>(value.unsafeBitCast(to: type))
2730
}
2831

32+
/// Returns the value created by fetching the property at `keyPath`
33+
/// of `self`.
2934
public subscript<Member>(keyPath: KeyPath<Value, Member>) -> _GraphValue<Member> {
3035
_GraphValue<Member>(value[keyPath: keyPath])
3136
}

Sources/OpenSwiftUI/Core/Modifier/ModifiedContent.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ extension ModifiedContent: ViewModifier where Content: ViewModifier, Modifier: V
111111
}
112112

113113
extension ViewModifier {
114+
/// Returns a new modifier that is the result of concatenating
115+
/// `self` with `modifier`.
114116
@inlinable
115117
@inline(__always)
116118
public func concat<T>(_ modifier: T) -> ModifiedContent<Self, T> {

Sources/OpenSwiftUI/Core/Modifier/ViewModifier/ViewModifier.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
/// caption in blue text surrounded by a rounded
5050
/// rectangle.](OpenSwiftUI-View-ViewModifier.png)
5151
public protocol ViewModifier {
52+
/// The type of view representing the body.
5253
associatedtype Body: View
5354

55+
/// Makes a new view using the view modifier and inputs that you provide.
5456
static func _makeView(
5557
modifier: _GraphValue<Self>,
5658
inputs: _ViewInputs,
@@ -63,11 +65,14 @@ public protocol ViewModifier {
6365
body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs
6466
) -> _ViewListOutputs
6567

68+
/// The number of views that `_makeViewList()` would produce, or
69+
/// nil if unknown.
6670
static func _viewListCount(
6771
inputs: _ViewListCountInputs,
6872
body: (_ViewListCountInputs) -> Int?
6973
) -> Int?
7074

75+
/// The content view type passed to `body()`.
7176
typealias Content = _ViewModifier_Content<Self>
7277

7378
/// Gets the current body of the caller.

Sources/OpenSwiftUI/Core/View/ConditionalContent.swift

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

99
internal import OpenGraphShims
1010

11+
/// View content that shows one of two possible children.
1112
@frozen
1213
public struct _ConditionalContent<TrueContent, FalseContent> {
1314
@usableFromInline

Sources/OpenSwiftUI/Core/View/View.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public protocol View {
7676
}
7777

7878
extension View {
79+
/// Instantiates the view using `view` as its source value, and
80+
/// `inputs` as its input values. Returns the view's output values.
81+
/// This should never be called directly, instead use the
82+
/// makeDebuggableView() shim function.
7983
public static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
8084
makeView(view: view, inputs: inputs)
8185
}

Sources/OpenSwiftUI/Core/View/View/ViewInputs.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
internal import OpenGraphShims
99

10+
/// The input (aka inherited) attributes supplied to each view. Most
11+
/// view types will only actually wire a small number of these into
12+
/// their node. Doesn't include the view itself, which is passed
13+
/// separately.
1014
public struct _ViewInputs {
1115
private var base: _GraphInputs
1216
var preferences: PreferencesInputs

Sources/OpenSwiftUI/Core/View/View/ViewOutputs.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
internal import OpenGraphShims
22

3+
/// The output (aka synthesized) attributes returned by each view.
34
public struct _ViewOutputs {
45
private var preferences = PreferencesOutputs()
56
@OptionalAttribute var layoutComputer: LayoutComputer?

Sources/OpenSwiftUI/Core/View/ViewList/ViewListCountInputs.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Audited for RELEASE_2021
66
// Status: WIP
77

8+
/// Input values to `View._viewListCount()`.
89
public struct _ViewListCountInputs {
910
var customInputs : PropertyList
1011
var options : _ViewListInputs.Options

Sources/OpenSwiftUI/Core/View/ViewList/ViewListInputs.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
internal import OpenGraphShims
99

10+
/// Input values to `View._makeViewList()`.
1011
public struct _ViewListInputs {
1112
private var base: _GraphInputs
1213
var implicitID: Int

Sources/OpenSwiftUI/Core/View/ViewList/ViewListOutputs.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
internal import OpenGraphShims
99

10+
/// Output values from `View._makeViewList()`.
1011
public struct _ViewListOutputs {
1112
var views: Views
1213
var nextImplicitID: Int

Sources/OpenSwiftUI/Data/Model/DynamicProperty/DynamicProperty.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ internal import OpenGraphShims
1414
/// The view gives values to these properties prior to recomputing the view's
1515
/// ``View/body-swift.property``.
1616
public protocol DynamicProperty {
17+
/// Creates an instance of the dynamic `View` property
18+
/// represented by `self`.
1719
static func _makeProperty<Value>(
1820
in buffer: inout _DynamicPropertyBuffer,
1921
container: _GraphValue<Value>,

Sources/OpenSwiftUI/View/Debug/ChangedBodyProperty.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,29 @@ import Foundation
1212
// MARK: - printChanges
1313

1414
extension View {
15+
/// When called within an invocation of `body` of a view of this
16+
/// type, prints the names of the changed dynamic properties that
17+
/// caused the result of `body` to need to be refreshed. As well as
18+
/// the physical property names, "@self" is used to mark that the
19+
/// view value itself has changed, and "@identity" to mark that the
20+
/// identity of the view has changed (i.e. that the persistent data
21+
/// associated with the view has been recycled for a new instance
22+
/// of the same type).
1523
public static func _printChanges() {
1624
printChangedBodyProperties(of: Self.self)
1725
}
1826
}
1927

2028
extension ViewModifier {
29+
/// When called within an invocation of `body()` of a view modifier
30+
/// of this type, prints the names of the changed dynamic
31+
/// properties that caused the result of `body()` to need to be
32+
/// refreshed. As well as the physical property names, "@self" is
33+
/// used to mark that the modifier value itself has changed, and
34+
/// "@identity" to mark that the identity of the modifier has
35+
/// changed (i.e. that the persistent data associated with the
36+
/// modifier has been recycled for a new instance of the same
37+
/// type).
2138
public static func _printChanges() {
2239
printChangedBodyProperties(of: Self.self)
2340
}
@@ -58,12 +75,45 @@ extension OSLog {
5875
#endif
5976

6077
extension View {
78+
/// When called within an invocation of `body` of a view of this type, logs
79+
/// the names of the changed dynamic properties that caused the result of
80+
/// `body` to need to be refreshed.
81+
///
82+
/// var body: some View {
83+
/// let _ = Self._logChanges()
84+
/// ... view content ...
85+
/// }
86+
///
87+
/// As well as the physical property names, "@self" is used to mark that the
88+
/// view value itself has changed, and "@identity" to mark that the identity
89+
/// of the view has changed (i.e. that the persistent data associated with
90+
/// the view has been recycled for a new instance of the same type).
91+
///
92+
/// The information is logged at the info level to the "org.OpenSwiftUIProject.OpenSwiftUI"
93+
/// subsystem with the category "Changed Body Properties".
6194
public static func _logChanges() {
6295
logChangedBodyProperties(of: Self.self)
6396
}
6497
}
6598

6699
extension ViewModifier {
100+
/// When called within an invocation of `body` of a view modifier of this
101+
/// type, logs the names of the changed dynamic properties that caused the
102+
/// result of `body` to need to be refreshed.
103+
///
104+
/// func body(content: Self.Content): Self.Body {
105+
/// let _ = Self._logChanges()
106+
/// ... view modifier content ...
107+
/// }
108+
///
109+
/// As well as the physical property names, "@self" is used to mark that the
110+
/// modifier value itself has changed, and "@identity" to mark that the
111+
/// identity of the modifier has changed (i.e. that the persistent data
112+
/// associated with the modifier has been recycled for a new instance of the
113+
/// same type).
114+
///
115+
/// The information is logged at the info level to the "org.OpenSwiftUIProject.OpenSwiftUI"
116+
/// subsystem with the category "Changed Body Properties".
67117
public static func _logChanges() {
68118
logChangedBodyProperties(of: Self.self)
69119
}

0 commit comments

Comments
 (0)