Skip to content

Commit 410b1d1

Browse files
authored
documentation updates and swiftformat pass (#194)
1 parent e2bb692 commit 410b1d1

File tree

14 files changed

+64
-42
lines changed

14 files changed

+64
-42
lines changed

Sources/Automerge/Automerge.docc/Automerge.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Read <doc:FiveMinuteQuickstart> to get a quick taste of how to use Automerge, or
6868

6969
- ``Automerge/AutomergeText``
7070
- ``Automerge/Cursor``
71+
- ``Automerge/Position``
7172
- ``Automerge/Mark``
7273
- ``Automerge/ExpandMark``
7374

@@ -111,6 +112,7 @@ Read <doc:FiveMinuteQuickstart> to get a quick taste of how to use Automerge, or
111112

112113
### Type Conversion Errors
113114

115+
- ``Automerge/ScalarValueConversionError``
114116
- ``Automerge/BooleanScalarConversionError``
115117
- ``Automerge/BytesScalarConversionError``
116118
- ``Automerge/IntScalarConversionError``

Sources/Automerge/Automerge.docc/Curation/Codable/AutomergeEncoder.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var myColors = ColorList(colors: ["blue", "red"])
1717
try encoder.encode(myColors)
1818
```
1919

20+
To support cross-platform usage, when provided a optional type to encode, the encoder writes a
21+
``ScalarValue/Null`` into the Document as opposed to not creating the relevant entry in a map or list.
22+
2023
## Topics
2124

2225
### Creating an Encoder

Sources/Automerge/Automerge.docc/Curation/Document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
### Observing Documents
126126

127127
- ``objectWillChange``
128+
- ``objectDidChange``
128129

129130
### Transfering Documents
130131

Sources/Automerge/BoundTypes/AutomergeText.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public final class AutomergeText: Codable, @unchecked Sendable {
224224
/// document.
225225
/// - Parameters:
226226
/// - doc: The Automerge document associated with this reference.
227-
/// - path: A string path that represents a `Text` container within the Automerge document.
227+
/// - id: The Automerge object ID of the text object to bind.
228228
public func bind(doc: Document, id: ObjId) throws {
229229
// this assert runs afoul of the encoder, which doesn't make sense right now, but
230230
// I don't want to second guess it at the moment.

Sources/Automerge/ChangeHash.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public struct ChangeHash: Equatable, Hashable, CustomDebugStringConvertible, Sen
1212
}
1313

1414
public extension Set<ChangeHash> {
15-
1615
/// Transforms each `ChangeHash` in the set into its byte array (`[UInt8]`). This raw byte representation
1716
/// captures the state of the document at a specific point in its history, allowing for efficient storage
1817
/// and retrieval of document states.
@@ -25,16 +24,16 @@ public extension Set<ChangeHash> {
2524
}
2625

2726
public extension Data {
28-
29-
/// Interprets the data to return the data as a set of change hashes that represent a state within an Automerge document. If the data is not a multiple of 32 bytes, returns nil.
27+
/// Interprets the data to return the data as a set of change hashes that represent a state within an Automerge
28+
/// document. If the data is not a multiple of 32 bytes, returns nil.
3029
func heads() -> Set<ChangeHash>? {
3130
let rawBytes: [UInt8] = Array(self)
3231
guard rawBytes.count % 32 == 0 else { return nil }
3332
let totalHashes = rawBytes.count / 32
34-
let heads = (0..<totalHashes).map { index in
33+
let heads = (0 ..< totalHashes).map { index in
3534
let lowerBound = index * 32
3635
let upperBound = (index + 1) * 32
37-
let bytes = rawBytes[lowerBound..<upperBound]
36+
let bytes = rawBytes[lowerBound ..< upperBound]
3837
return ChangeHash(bytes: Array(bytes))
3938
}
4039
return Set(heads)

Sources/Automerge/Codable/AnyCodingKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension AnyCodingKey: CodingKey {
6767
///
6868
/// For a non-failable initializer for ``AnyCodingKey``, use ``AnyCodingKey/init(_:)-5azuh``.
6969
///
70-
/// - Parameter stringVal: The key for a keyed container.
70+
/// - Parameter stringValue: The key for a keyed container.
7171
public init?(stringValue: String) {
7272
pathElement = Automerge.Prop.Key(stringValue)
7373
}

Sources/Automerge/Codable/Decoding/AutomergeDecoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct AutomergeDecoder {
1414
}
1515

1616
/// Returns the type you specify, decoded from the Automerge document referenced by the decoder.
17-
/// - Parameter _: _ The type of the value to decode from the Automerge document.
17+
/// - Parameter : The type of the value to decode from the Automerge document.
1818
@inlinable public func decode<T: Decodable>(_: T.Type) throws -> T {
1919
if T.self == AutomergeText.self {
2020
// Special case decoding AutomergeText - when it's the top level type being encoded,
@@ -37,8 +37,8 @@ public struct AutomergeDecoder {
3737

3838
/// Returns the type you specify, decoded from the Automerge document referenced by the decoder.
3939
/// - Parameters:
40-
/// - _: _ The type of the value to decode from the Automerge document.
41-
/// - path: The path to the schema location within the Automerge document to attempt to decode into the type you
40+
/// - : The type of the value to decode from the Automerge document.
41+
/// - path: The path to the schema location within the Automerge document to attempt to decode into the type you
4242
/// provide.
4343
///
4444
/// The `path` parameter accepts any type conforming to the `CodingKey` protocol.

Sources/Automerge/Codable/Decoding/AutomergeSingleValueDecodingContainer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ struct AutomergeSingleValueDecodingContainer: SingleValueDecodingContainer {
184184
debugDescription: "Expected to decode \(T.self) from \(value), but it wasn't `.text`."
185185
))
186186
}
187-
188187
default:
189188
return try T(from: impl)
190189
}

Sources/Automerge/Codable/Encoding/AutomergeEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// An encoder that stores types that conform to the codable protocol into an Automerge document.
1+
/// An encoder that stores types that conform to the Codable protocol into an Automerge document.
22
public struct AutomergeEncoder {
33
/// The user info dictionary for the encoder.
44
public var userInfo: [CodingUserInfoKey: Any] = [:]

Sources/Automerge/Cursor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public enum Position {
3333
extension Position {
3434
func toFfi() -> FfiPosition {
3535
switch self {
36-
case .cursor(let cursor):
36+
case let .cursor(cursor):
3737
return .cursor(position: cursor.bytes)
38-
case .index(let index):
38+
case let .index(index):
3939
return .index(position: index)
4040
}
4141
}

0 commit comments

Comments
 (0)