1
1
/*
2
- This source file is part of the Swift.org open source project
2
+ This source file is part doccof the Swift.org open source project
3
3
4
4
Copyright (c) 2024 Apple Inc. and the Swift project authors
5
5
Licensed under Apache License v2.0 with Runtime Library Exception
@@ -36,7 +36,9 @@ extension Docc.ProcessArchive {
36
36
" \( frameworkName. localizedCapitalized) _ChangeLog.md " : """
37
37
# \( frameworkName. localizedCapitalized) Updates
38
38
39
- @Metadata { @PageColor(yellow) }
39
+ @Metadata {
40
+ @PageColor(yellow)
41
+ }
40
42
41
43
Learn about important changes to \( frameworkName. localizedCapitalized) .
42
44
@@ -222,6 +224,48 @@ extension Docc.ProcessArchive {
222
224
}
223
225
}
224
226
227
+ // TODO: CONTINUE
228
+ // func findPageType(symbolPath: URL) throws -> URL? {
229
+ // struct ContainerWithPageType: Codable {
230
+ // var pageType: NavigatorIndex.PageType
231
+ // }
232
+ //
233
+ // let renderJSONData = try Data(contentsOf: symbolPath)
234
+ // let decoder = RenderJSONDecoder.makeDecoder()
235
+ //
236
+ // do {
237
+ // let identifier = try decoder.decode(NavigatorIndex.self, from: renderJSONData).
238
+ // return identifier.url
239
+ // } catch {
240
+ // return nil
241
+ // }
242
+ // }
243
+
244
+ func findClassName( symbolPath: URL ) -> String {
245
+ return symbolPath. lastPathComponent
246
+ }
247
+
248
+ // func findClassName(symbolPath: URL) throws -> [[String]]? {
249
+ // struct ContainerWithRenderHierarchy: Codable {
250
+ // var hierarchy: RenderHierarchy
251
+ // }
252
+ //
253
+ // let renderJSONData = try Data(contentsOf: symbolPath)
254
+ // let decoder = RenderJSONDecoder.makeDecoder()
255
+ //
256
+ // do {
257
+ // let hierarchy = try decoder.decode(ContainerWithRenderHierarchy.self, from: renderJSONData).hierarchy
258
+ //
259
+ // if hierarchy != nil {
260
+ // return hierarchy.paths
261
+ // }
262
+ //
263
+ // return identifier.url
264
+ // } catch {
265
+ // return nil
266
+ // }
267
+ // }
268
+
225
269
/// Process lists of symbols to group them according to the highest level path component, split by spaces.
226
270
func groupSymbols( symbolLinks: Set < URL > , frameworkName: String ) -> String {
227
271
// Sort list alphabetically
@@ -239,7 +283,7 @@ extension Docc.ProcessArchive {
239
283
240
284
// If there are no common path components, add a space. Then reset the first to find the next parent.
241
285
if parent. localizedLowercase. hasSuffix ( frameworkName + " / " ) {
242
- links. append ( " \n \n " )
286
+ links. append ( " \n \n " )
243
287
first = symbol
244
288
}
245
289
@@ -248,6 +292,37 @@ extension Docc.ProcessArchive {
248
292
249
293
return links
250
294
}
295
+
296
+ func addClassNames( allSymbolsString: String ) -> String {
297
+ // let processedString = ""
298
+
299
+ // Split string into string array on a double newline
300
+ return longestCommonPrefix ( of: allSymbolsString)
301
+ }
302
+
303
+ func longestCommonPrefix( of string: String ) -> String {
304
+
305
+ let words = string. split ( separator: " " )
306
+ // let words = string.split(separator: "\n\n")
307
+ guard let first = words. first else {
308
+ return " "
309
+ }
310
+
311
+ var ( minWord, maxWord) = ( first, first)
312
+ for word in words. dropFirst ( ) {
313
+ if word < minWord {
314
+ print ( word)
315
+ print ( maxWord)
316
+ minWord = word
317
+ } else if word > maxWord {
318
+ print ( word)
319
+ print ( maxWord)
320
+ maxWord = word
321
+ }
322
+ }
323
+
324
+ return minWord. commonPrefix ( with: maxWord)
325
+ }
251
326
252
327
}
253
328
}
0 commit comments