Skip to content

Commit 7b7d10e

Browse files
committed
Improve documentation in MutateID.swift by adding missing comments for methods and properties, enhancing clarity on mutation ID functionality and usage.
1 parent 183a3a5 commit 7b7d10e

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

Sources/VDFlow/MutateID.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Foundation
77
public struct MutateID: Comparable, Hashable, Codable, Sendable {
88

99
/// The timestamp of the mutation, represented as uptime nanoseconds.
10-
///
10+
///
1111
/// A `nil` value indicates that no mutation has occurred yet.
1212
var mutationDate: UInt64?
1313

1414
/// Creates a new mutation ID with no timestamp.
1515
public init() {}
1616

1717
/// Creates a mutation ID by decoding it from a decoder.
18-
///
18+
///
1919
/// - Parameter decoder: The decoder to read data from.
2020
/// - Throws: An error if decoding fails.
2121
public init(from decoder: Decoder) throws {
@@ -24,22 +24,22 @@ public struct MutateID: Comparable, Hashable, Codable, Sendable {
2424
}
2525

2626
/// Encodes the mutation ID to an encoder.
27-
///
27+
///
2828
/// - Parameter encoder: The encoder to write data to.
2929
/// - Throws: An error if encoding fails.
3030
public func encode(to encoder: Encoder) throws {
3131
try (mutationDate ?? 0).encode(to: encoder)
3232
}
3333

3434
/// Updates the mutation ID with the current timestamp.
35-
///
35+
///
3636
/// This method sets the `mutationDate` to the current system uptime in nanoseconds.
37-
mutating func update() {
37+
public mutating func update() {
3838
mutationDate = DispatchTime.now().uptimeNanoseconds
3939
}
4040

4141
/// Compares two mutation IDs chronologically.
42-
///
42+
///
4343
/// - Parameters:
4444
/// - lhs: The left-hand side mutation ID.
4545
/// - rhs: The right-hand side mutation ID.
@@ -49,7 +49,7 @@ public struct MutateID: Comparable, Hashable, Codable, Sendable {
4949
}
5050

5151
/// Converts this mutation ID to an optional, returning `nil` if no mutation has occurred.
52-
///
52+
///
5353
/// - Returns: This mutation ID if it has a timestamp, otherwise `nil`.
5454
var optional: MutateID? {
5555
mutationDate.map { _ in self }

Sources/VDFlowMacros/StepsMacro.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ public struct StepsMacro: MemberAttributeMacro, ExtensionMacro, MemberMacro, Acc
268268
type = "Int"
269269
} else if value.is(FloatLiteralExprSyntax.self) {
270270
type = "Double"
271-
} else if let typeName = value.baseName, typeName.first?.isLowercase == false {
272-
type = typeName
273-
} else {
271+
} else if let typeName = value.baseName, typeName.first?.isLowercase == false {
272+
type = typeName
273+
} else {
274274
throw MacroError("Type of `\(name)` must be provided explicitly with `:`")
275275
}
276276
} else {
@@ -320,21 +320,21 @@ public struct StepsMacro: MemberAttributeMacro, ExtensionMacro, MemberMacro, Acc
320320
get { if let result = lastMutateStepID { return result.0 } else { return \(raw: defaultValue) } }
321321
set {
322322
guard let selection = Self._selections[newValue] else {
323-
\(raw: hasDeselected ? "_deselectedMutateID._update()" : "")
323+
\(raw: hasDeselected ? "_deselectedMutateID.update()" : "")
324324
return
325325
}
326326
selection(&self)
327327
}
328328
}
329329
"""
330330
result.append(selected)
331-
332-
let isSelected: DeclSyntax =
333-
"""
334-
public func isSelected<T>(_ keyPath: WritableKeyPath<Self, StepID<T>>) -> Bool {
335-
selected == self[keyPath: keyPath].id
336-
}
337-
"""
331+
332+
let isSelected: DeclSyntax =
333+
"""
334+
public func isSelected<T>(_ keyPath: WritableKeyPath<Self, StepID<T>>) -> Bool {
335+
selected == self[keyPath: keyPath].id
336+
}
337+
"""
338338
result.append(isSelected)
339339

340340
let typealiasDecl: DeclSyntax = "public typealias AllSteps = \(raw: stepsType)"
@@ -476,11 +476,11 @@ private extension String {
476476
}
477477

478478
private extension ExprSyntax {
479-
480-
var baseName: String? {
481-
self.as(FunctionCallExprSyntax.self)?.calledExpression.as(DeclReferenceExprSyntax.self)?.baseName.trimmed.text ??
482-
self.as(FunctionCallExprSyntax.self)?.calledExpression.as(GenericSpecializationExprSyntax.self)?.trimmed.description
483-
}
479+
480+
var baseName: String? {
481+
self.as(FunctionCallExprSyntax.self)?.calledExpression.as(DeclReferenceExprSyntax.self)?.baseName.trimmed.text ??
482+
self.as(FunctionCallExprSyntax.self)?.calledExpression.as(GenericSpecializationExprSyntax.self)?.trimmed.description
483+
}
484484
}
485485

486486
private struct MacroError: LocalizedError, CustomStringConvertible {

0 commit comments

Comments
 (0)