@@ -105,10 +105,6 @@ extension Docc.ProcessArchive {
105
105
let additionsToNewSet = newSet. subtracting ( initialSet)
106
106
let removedFromOldSet = initialSet. subtracting ( newSet)
107
107
108
- // Map identifier urls in differences to external urls
109
- let additionsExternalURLs = Set ( additionsToNewSet. map { findExternalLink ( identifierURL: $0) } )
110
- let removalsExternalURLs = Set ( removedFromOldSet. map { findExternalLink ( identifierURL: $0) } )
111
-
112
108
// The framework name is the path component after "/documentation/".
113
109
var frameworkName : String = " No_Framework_Name "
114
110
var potentialFrameworkName = try findFrameworkName ( initialPath: initialDocCArchivePath)
@@ -120,24 +116,8 @@ extension Docc.ProcessArchive {
120
116
frameworkName = potentialFrameworkName ?? " No_Framework_Name "
121
117
}
122
118
123
-
124
- let additionLinks = groupSeparateSymbols ( symbolLinks: additionsExternalURLs)
125
- let removalLinks = groupSeparateSymbols ( symbolLinks: removalsExternalURLs)
126
-
127
-
128
-
129
- // let sortedAdditionSymbols = groupSeparateSymbols(symbolLinks: additionsExternalURLs)
130
- // let sortedRemovalSymbols = groupSeparateSymbols(symbolLinks: removalsExternalURLs)
131
- //
132
- // var additionLinks: String = ""
133
- // for addition in sortedAdditionSymbols {
134
- // additionLinks.append("\n- <\(addition)>")
135
- // }
136
- //
137
- // var removalLinks: String = ""
138
- // for removal in sortedRemovalSymbols {
139
- // removalLinks.append("\n- <\(removal)>")
140
- // }
119
+ let additionLinks = groupSymbols ( symbolLinks: additionsToNewSet, frameworkName: frameworkName)
120
+ let removalLinks = groupSymbols ( symbolLinks: removedFromOldSet, frameworkName: frameworkName)
141
121
142
122
// Create markdown file with changes in the newer DocC Archive that do not exist in the initial DocC Archive.
143
123
for fileNameAndContent in Docc . ProcessArchive. DiffDocCArchive. changeLogTemplateFileContent ( frameworkName: frameworkName, initialDocCArchiveVersion: initialDocCArchiveVersion, newerDocCArchiveVersion: newerDocCArchiveVersion, additionLinks: additionLinks, removalLinks: removalLinks) {
@@ -242,31 +222,31 @@ extension Docc.ProcessArchive {
242
222
}
243
223
}
244
224
245
- /// Process lists of symbols to group them according to the highest level path component.
246
- ///
247
- /// If a class didn't exist in the old version but now exists in the new version:
248
- /// - print that a new class was added,
249
- /// - display the number of symbols added within that class beside it.
250
- ///
251
- /// Otherwise, group symbols by their highest path component below a header, and then print a nested list.
252
- func groupSeparateSymbols( symbolLinks: Set < String > ) -> String {
253
-
225
+ /// Process lists of symbols to group them according to the highest level path component, split by spaces.
226
+ func groupSymbols( symbolLinks: Set < URL > , frameworkName: String ) -> String {
254
227
// Sort list alphabetically
255
- let sortedSymbols : [ String ] = symbolLinks. sorted { $0. localizedCompare ( $1) == . orderedAscending }
256
-
257
- // Check matching path components
258
- // for each path component after the initial path component....
259
- // for symbol in sortedSymbols {
260
- // // example path components: ["/", "documentation", "accelerate", "vdsp", "vector-scalar_real_arithmetic_functions"]
261
- // print(symbol.pathComponents)
262
- // }
228
+ let sortedSymbols : [ URL ] = symbolLinks. sorted { $0. absoluteString. localizedCompare ( $1. absoluteString) == . orderedAscending }
263
229
264
230
var links : String = " "
265
- for symbol in sortedSymbols {
266
- links. append ( " \n - < \( symbol) > " )
231
+
232
+ // find most similar path up until framework name by iterating over path components one at a time
233
+ guard var first = sortedSymbols. first else {
234
+ return links
235
+ }
236
+
237
+ for symbol in sortedSymbols. dropFirst ( ) {
238
+ let parent : String = first. absoluteString. commonPrefix ( with: symbol. absoluteString)
239
+
240
+ // If there are no common path components, add a space. Then reset the first to find the next parent.
241
+ if parent. localizedLowercase. hasSuffix ( frameworkName + " / " ) {
242
+ links. append ( " \n \n " )
243
+ first = symbol
244
+ }
245
+
246
+ links. append ( " \n - < \( findExternalLink ( identifierURL: symbol) ) > " )
267
247
}
268
248
269
- return links // TODO: STUB
249
+ return links
270
250
}
271
251
272
252
}
0 commit comments