Skip to content

Commit 50346a8

Browse files
committed
Add logic to return added/removed symbols in an alphabetical list.
1 parent 278b3c2 commit 50346a8

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,24 @@ extension Docc.ProcessArchive {
120120
frameworkName = potentialFrameworkName ?? "No_Framework_Name"
121121
}
122122

123-
var additionLinks: String = ""
124-
for addition in additionsExternalURLs {
125-
additionLinks.append("\n- <\(addition)>")
126-
}
127123

128-
var removalLinks: String = ""
129-
for removal in removalsExternalURLs {
130-
removalLinks.append("\n- <\(removal)>")
131-
}
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+
// }
132141

133142
// Create markdown file with changes in the newer DocC Archive that do not exist in the initial DocC Archive.
134143
for fileNameAndContent in Docc.ProcessArchive.DiffDocCArchive.changeLogTemplateFileContent(frameworkName: frameworkName, initialDocCArchiveVersion: initialDocCArchiveVersion, newerDocCArchiveVersion: newerDocCArchiveVersion, additionLinks: additionLinks, removalLinks: removalLinks) {
@@ -232,6 +241,33 @@ extension Docc.ProcessArchive {
232241
return nil
233242
}
234243
}
244+
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+
254+
// 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+
// }
263+
264+
var links: String = ""
265+
for symbol in sortedSymbols {
266+
links.append("\n- <\(symbol)>")
267+
}
268+
269+
return links // TODO: STUB
270+
}
235271

236272
}
237273
}

0 commit comments

Comments
 (0)