Skip to content

Commit f7ba528

Browse files
committed
Adding more documentation
1 parent 54a700c commit f7ba528

14 files changed

+137
-70
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ The `ChangeConsolidator` takes 2 independent changes (`addition` & `removal`) an
4141

4242
### OutputGenerator
4343

44-
Receives a list of `Change`s and processes them into a human readable format.
44+
Receives a dictionary of `[{SCOPE_NAME}: [Change]]` and processes them into a human readable format.
45+
46+
## Inspiration
47+
- SwiftInterfaceParser: https://github.com/sdidla/Hatch/blob/main/Sources/Hatch/SymbolParser.swift

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class SwiftInterfaceActor: SwiftInterfaceElement, SwiftInterfaceExtendableElement {
3+
class SwiftInterfaceActor: SwiftInterfaceExtendableElement {
44

55
var pathComponentName: String { name }
66

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Class.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class SwiftInterfaceClass: SwiftInterfaceElement, SwiftInterfaceExtendableElement {
3+
class SwiftInterfaceClass: SwiftInterfaceExtendableElement {
44

55
/// e.g. @discardableResult, @MainActor, @objc, @_spi(...), ...
66
let attributes: [String]

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class SwiftInterfaceEnum: SwiftInterfaceElement, SwiftInterfaceExtendableElement {
3+
class SwiftInterfaceEnum: SwiftInterfaceExtendableElement {
44

55
/// e.g. @discardableResult, @MainActor, @objc, @_spi(...), ...
66
let attributes: [String]

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Protocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class SwiftInterfaceProtocol: SwiftInterfaceElement, SwiftInterfaceExtendableElement {
3+
class SwiftInterfaceProtocol: SwiftInterfaceExtendableElement {
44

55
/// e.g. @discardableResult, @MainActor, @objc, @_spi(...), ...
66
let attributes: [String]

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Struct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class SwiftInterfaceStruct: SwiftInterfaceElement, SwiftInterfaceExtendableElement {
3+
class SwiftInterfaceStruct: SwiftInterfaceExtendableElement {
44

55
/// e.g. @discardableResult, @MainActor, @objc, @_spi(...), ...
66
let attributes: [String]

Sources/Helpers/Models/SwiftInterface/SwiftInterfaceElement.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
protocol SwiftInterfaceExtendableElement: AnyObject {
3+
protocol SwiftInterfaceExtendableElement: SwiftInterfaceElement {
44

55
/// Name of the type
66
///
@@ -51,6 +51,12 @@ extension SwiftInterfaceElement {
5151
}
5252
}
5353

54+
/// The path to the parent based on the `pathComponentName`
55+
///
56+
/// The path does not including the own `pathComponentName`
57+
///
58+
/// - Important: `SwiftInterfaceExtension`'s parentPath is always the `extendedType`
59+
/// of the element to group them under the extended element
5460
var parentPath: String {
5561
if let extensionElement = self as? SwiftInterfaceExtension {
5662
// We want to group all extensions under the type that they are extending
@@ -105,6 +111,7 @@ extension SwiftInterfaceElement {
105111

106112
extension SwiftInterfaceElement {
107113

114+
/// Produces the complete recursive description of the element
108115
func recursiveDescription(indentation: Int = 0) -> String {
109116
let spacer = " "
110117
var recursiveDescription = "\(String(repeating: spacer, count: indentation))\(description)"

Sources/Helpers/SwiftInterfaceType.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import ArgumentParser
33

4+
/// The type of the .swiftinterface to parse/generate
45
enum SwiftInterfaceType {
56
case `private`
67
case `public`

Sources/Helpers/XcodeTools.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct XcodeToolsError: LocalizedError, CustomDebugStringConvertible {
1616
struct XcodeTools {
1717

1818
internal enum Constants {
19-
static let deviceTarget: String = "x86_64-apple-ios17.4-simulator" // TODO: Match the iOS version to the sdk
2019
static let derivedDataPath: String = ".build"
2120
static let simulatorSdkCommand = "xcrun --sdk iphonesimulator --show-sdk-path"
2221
}
@@ -82,8 +81,4 @@ struct XcodeTools {
8281
return derivedDataPath
8382
}.value
8483
}
85-
86-
private var iOSTarget: String {
87-
"-sdk `\(Constants.simulatorSdkCommand)` -target \(Constants.deviceTarget)"
88-
}
8984
}

Sources/Pipeline/Modules/SwiftInterfaceAnalyzer/SwiftInterfaceAnalyzer.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import Foundation
88

99
struct SwiftInterfaceAnalyzer: SwiftInterfaceAnalyzing {
1010

11-
// TODO: Surface changes that happened to a subclass/protocol/extension
12-
1311
let changeConsolidator: SwiftInterfaceChangeConsolidating
1412

1513
init(
@@ -23,6 +21,9 @@ struct SwiftInterfaceAnalyzer: SwiftInterfaceAnalyzing {
2321
new: some SwiftInterfaceElement
2422
) -> [Change] {
2523

24+
// Very naive diff from both sides
25+
// There is room for improvement here but it's "performant enough" for now
26+
2627
let individualChanges = Self.recursiveCompare(
2728
element: old,
2829
to: new,

0 commit comments

Comments
 (0)