Skip to content

Commit b139d90

Browse files
committed
Update documentation to match OpenSwiftUI docc format
- Replace markdown code fences with indented code blocks (4 spaces) - Update main documentation categories (Architecture -> Essentials) - Follow OpenSwiftUI documentation patterns and conventions - Maintain consistent formatting across all swift-docc files
1 parent b86a476 commit b139d90

File tree

6 files changed

+70
-91
lines changed

6 files changed

+70
-91
lines changed

.claude/settings.local.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"permissions": {
3+
"additionalDirectories": [
4+
"/Users/kyle/Workspace/OpenSwiftUIProject/OpenSwiftUI/Sources/OpenSwiftUI/OpenSwiftUI.docc/"
5+
]
6+
}
7+
}

Sources/OpenAttributeGraph/Attribute/Attribute/Attribute.swift

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ public import OpenAttributeGraphCxx
55
/// `Attribute` is the core building block of the OpenAttributeGraph reactive system. When you wrap a property
66
/// with `@Attribute`, it becomes reactive and can automatically track dependencies and propagate changes.
77
///
8-
/// ```swift
9-
/// @Attribute var count: Int = 0
10-
/// @Attribute var doubledCount: Int = count * 2
11-
///
12-
/// count = 5 // doubledCount automatically becomes 10
13-
/// ```
8+
/// @Attribute var count: Int = 0
9+
/// @Attribute var doubledCount: Int = count * 2
10+
///
11+
/// count = 5 // doubledCount automatically becomes 10
1412
///
1513
/// ## Key Features
1614
///
@@ -24,44 +22,38 @@ public import OpenAttributeGraphCxx
2422
///
2523
/// Use `@Attribute` to make any Swift value reactive:
2624
///
27-
/// ```swift
28-
/// struct CounterView {
29-
/// @Attribute var count: Int = 0
30-
///
31-
/// var body: some View {
32-
/// Button("Count: \(count)") {
33-
/// count += 1
25+
/// struct CounterView {
26+
/// @Attribute var count: Int = 0
27+
///
28+
/// var body: some View {
29+
/// Button("Count: \(count)") {
30+
/// count += 1
31+
/// }
3432
/// }
3533
/// }
36-
/// }
37-
/// ```
3834
///
3935
/// ## Dynamic Member Lookup
4036
///
4137
/// Access nested properties as separate attributes:
4238
///
43-
/// ```swift
44-
/// @Attribute var person: Person = Person(name: "Alice", age: 30)
45-
/// let nameAttribute: Attribute<String> = person.name
46-
/// let ageAttribute: Attribute<Int> = person.age
47-
/// ```
39+
/// @Attribute var person: Person = Person(name: "Alice", age: 30)
40+
/// let nameAttribute: Attribute<String> = person.name
41+
/// let ageAttribute: Attribute<Int> = person.age
4842
///
4943
/// ## Integration with Rules
5044
///
5145
/// Create computed attributes using ``Rule`` or ``StatefulRule``:
5246
///
53-
/// ```swift
54-
/// struct DoubledRule: Rule {
55-
/// typealias Value = Int
56-
/// let source: Attribute<Int>
57-
///
58-
/// func value() -> Int {
59-
/// source.wrappedValue * 2
47+
/// struct DoubledRule: Rule {
48+
/// typealias Value = Int
49+
/// let source: Attribute<Int>
50+
///
51+
/// func value() -> Int {
52+
/// source.wrappedValue * 2
53+
/// }
6054
/// }
61-
/// }
6255
///
63-
/// let doubled = Attribute(DoubledRule(source: count))
64-
/// ```
56+
/// let doubled = Attribute(DoubledRule(source: count))
6557
@frozen
6658
@propertyWrapper
6759
@dynamicMemberLookup
@@ -89,9 +81,7 @@ public struct Attribute<Value> {
8981
/// This initializer creates an external attribute that holds the provided value.
9082
/// External attributes are typically used for storing user input or initial state.
9183
///
92-
/// ```swift
93-
/// let count = Attribute(value: 42)
94-
/// ```
84+
/// let count = Attribute(value: 42)
9585
///
9686
/// - Parameter value: The initial value for the attribute
9787
public init(value: Value) {
@@ -145,12 +135,10 @@ public struct Attribute<Value> {
145135
/// Getting this value may trigger dependency tracking in the current evaluation context.
146136
/// Setting this value will update the attribute and invalidate any dependents.
147137
///
148-
/// ```swift
149-
/// @Attribute var count: Int = 0
150-
///
151-
/// print(count) // Gets wrappedValue, returns 0
152-
/// count = 5 // Sets wrappedValue, triggers updates
153-
/// ```
138+
/// @Attribute var count: Int = 0
139+
///
140+
/// print(count) // Gets wrappedValue, returns 0
141+
/// count = 5 // Sets wrappedValue, triggers updates
154142
public var wrappedValue: Value {
155143
unsafeAddress {
156144
OAGGraphGetValue(identifier, type: Value.self)
@@ -166,12 +154,10 @@ public struct Attribute<Value> {
166154
/// allowing you to pass the reactive attribute to other functions or create
167155
/// derived attributes.
168156
///
169-
/// ```swift
170-
/// @Attribute var count: Int = 0
171-
///
172-
/// let countAttribute = $count // Gets the Attribute<Int> object
173-
/// let doubled = countAttribute.map { $0 * 2 }
174-
/// ```
157+
/// @Attribute var count: Int = 0
158+
///
159+
/// let countAttribute = $count // Gets the Attribute<Int> object
160+
/// let doubled = countAttribute.map { $0 * 2 }
175161
public var projectedValue: Attribute<Value> {
176162
get { self }
177163
set { self = newValue }

Sources/OpenAttributeGraph/Attribute/Rule/Rule.swift

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,21 @@ public import OpenAttributeGraphCxx
1212
/// Rules provide a way to create derived attributes that compute their values based on other attributes.
1313
/// When any dependency changes, the rule will automatically recompute its value.
1414
///
15-
/// ```swift
16-
/// struct DoubledRule: Rule {
17-
/// typealias Value = Int
18-
/// let source: Attribute<Int>
19-
///
20-
/// var value: Int {
21-
/// source.wrappedValue * 2
15+
/// struct DoubledRule: Rule {
16+
/// typealias Value = Int
17+
/// let source: Attribute<Int>
18+
///
19+
/// var value: Int {
20+
/// source.wrappedValue * 2
21+
/// }
2222
/// }
23-
/// }
2423
///
25-
/// @Attribute var count: Int = 5
26-
/// let doubled = Attribute(DoubledRule(source: $count))
27-
/// // doubled.wrappedValue == 10
24+
/// @Attribute var count: Int = 5
25+
/// let doubled = Attribute(DoubledRule(source: $count))
26+
/// // doubled.wrappedValue == 10
2827
///
29-
/// count = 10
30-
/// // doubled.wrappedValue automatically becomes 20
31-
/// ```
28+
/// count = 10
29+
/// // doubled.wrappedValue automatically becomes 20
3230
///
3331
/// ## Key Features
3432
///
@@ -65,12 +63,10 @@ public protocol Rule: _AttributeBody {
6563
/// the result. The attribute graph will automatically track these dependencies and
6664
/// invalidate this rule when any dependency changes.
6765
///
68-
/// ```swift
69-
/// var value: Int {
70-
/// // Dependencies are automatically tracked
71-
/// return source1.wrappedValue + source2.wrappedValue
72-
/// }
73-
/// ```
66+
/// var value: Int {
67+
/// // Dependencies are automatically tracked
68+
/// return source1.wrappedValue + source2.wrappedValue
69+
/// }
7470
var value: Value { get }
7571
}
7672

Sources/OpenAttributeGraph/OpenAttributeGraph.docc/Architecture.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@ The **Attribute layer** forms the foundation of the reactive system, providing t
1616

1717
**Property Wrapper Design**: At its heart, ``Attribute`` is a property wrapper that makes any Swift value reactive. When you wrap a value with `@Attribute`, it automatically gains dependency tracking capabilities:
1818

19-
```swift
20-
@Attribute var count: Int = 0
21-
```
19+
@Attribute var count: Int = 0
2220

2321
**Type Erasure**: ``AnyAttribute`` provides type-erased access to attributes, enabling runtime flexibility while maintaining type safety where possible.
2422

2523
**Rule-Based Transformations**: The ``Rule`` and ``StatefulRule`` protocols allow you to create computed attributes that automatically update when their dependencies change:
2624

27-
```swift
28-
struct DoubledRule: Rule {
29-
typealias Value = Int
30-
let source: Attribute<Int>
31-
32-
func value() -> Int {
33-
source.wrappedValue * 2
25+
struct DoubledRule: Rule {
26+
typealias Value = Int
27+
let source: Attribute<Int>
28+
29+
func value() -> Int {
30+
source.wrappedValue * 2
31+
}
3432
}
35-
}
36-
```
3733

3834
**Reference Semantics**: ``WeakAttribute`` and ``OptionalAttribute`` provide safe ways to handle optional and weak references within the attribute system.
3935

@@ -84,10 +80,8 @@ The **Runtime layer** provides the low-level type introspection and memory manag
8480

8581
This runtime introspection enables features like automatic KeyPath-based attribute access:
8682

87-
```swift
88-
@Attribute var person: Person = Person(name: "Alice", age: 30)
89-
let nameAttribute = person.name // Automatic attribute creation via KeyPath
90-
```
83+
@Attribute var person: Person = Person(name: "Alice", age: 30)
84+
let nameAttribute = person.name // Automatic attribute creation via KeyPath
9185

9286
#### Memory Management
9387

Sources/OpenAttributeGraph/OpenAttributeGraph.docc/OpenAttributeGraph.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The framework is designed for high performance and powers the reactive updates t
1010

1111
## Topics
1212

13-
### Architecture
13+
### Essentials
1414

1515
- <doc:Architecture-article>
1616

@@ -56,4 +56,4 @@ The framework is designed for high performance and powers the reactive updates t
5656

5757
#### Type System Support
5858
- ``External``
59-
- ``PointerOffset``
59+
- ``PointerOffset``

Sources/OpenAttributeGraph/Runtime/Metadata.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible {
3636
/// This initializer allows you to create runtime metadata for any Swift type,
3737
/// which can then be used for type introspection and comparison.
3838
///
39-
/// ```swift
40-
/// let intMetadata = Metadata(Int.self)
41-
/// let stringMetadata = Metadata(String.self)
42-
/// ```
39+
/// let intMetadata = Metadata(Int.self)
40+
/// let stringMetadata = Metadata(String.self)
4341
///
4442
/// - Parameter type: The Swift type to create metadata for
4543
public init(_ type: any Any.Type) {
@@ -51,10 +49,8 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible {
5149
/// This property allows you to convert from runtime metadata back to a Swift type,
5250
/// enabling dynamic type operations.
5351
///
54-
/// ```swift
55-
/// let metadata = Metadata(String.self)
56-
/// let type = metadata.type // Returns String.Type
57-
/// ```
52+
/// let metadata = Metadata(String.self)
53+
/// let type = metadata.type // Returns String.Type
5854
public var type: any Any.Type {
5955
unsafeBitCast(rawValue, to: Any.Type.self)
6056
}

0 commit comments

Comments
 (0)