@@ -16,56 +16,14 @@ extension Docc {
1616
1717 struct GenerateChangelog : ParsableCommand {
1818
19- // MARK: - Content and Configuration
19+ // MARK: - Configuration
2020
2121 /// Command line configuration.
2222 static var configuration = CommandConfiguration (
2323 commandName: " generate-changelog " ,
2424 abstract: " Generate a changelog with symbol diffs between documentation archives ('.doccarchive' directories). " ,
2525 shouldDisplay: true )
2626
27- /// Content of the 'changeLog' template.
28- static func changeLogTemplateFileContent(
29- frameworkName: String ,
30- initialDocCArchiveVersion: String ,
31- newerDocCArchiveVersion: String ,
32- additionLinks: String ,
33- removalLinks: String
34- ) -> [ String : String ] {
35- [
36- " \( frameworkName. localizedCapitalized) _Changelog.md " : """
37- # \( frameworkName. localizedCapitalized) Updates
38-
39- @Metadata {
40- @PageColor(yellow)
41- }
42-
43- Learn about important changes to \( frameworkName. localizedCapitalized) .
44-
45- ## Overview
46-
47- Browse notable changes in \( frameworkName. localizedCapitalized) .
48-
49- ## Diff between \( initialDocCArchiveVersion) and \( newerDocCArchiveVersion)
50-
51-
52- ### Change Log
53-
54- #### Additions
55- _New symbols added in \( newerDocCArchiveVersion) that did not previously exist in \( initialDocCArchiveVersion) ._
56-
57- \( additionLinks)
58-
59-
60- #### Removals
61- _Old symbols that existed in \( initialDocCArchiveVersion) that no longer exist in \( newerDocCArchiveVersion) ._
62-
63- \( removalLinks)
64-
65- """
66- ]
67- }
68-
6927
7028 // MARK: - Command Line Options & Arguments
7129
@@ -115,37 +73,32 @@ extension Docc {
11573 print ( " Showing ONLY high-level symbol diffs: modules, classes, protocols, and structs. " )
11674 }
11775
118- let initialSet = Set ( initialDocCArchiveAPIs. map { $0 } )
119- let newSet = Set ( newDocCArchiveAPIs. map { $0 } )
76+ let initialSet = Set ( initialDocCArchiveAPIs)
77+ let newSet = Set ( newDocCArchiveAPIs)
12078
12179 // Compute additions and removals to both sets
12280 let additionsToNewSet = newSet. subtracting ( initialSet)
12381 let removedFromOldSet = initialSet. subtracting ( newSet)
12482
12583 // The framework name is the path component after "/documentation/".
126- var frameworkName : String = " No_Framework_Name "
12784 var potentialFrameworkName = try findFrameworkName ( initialPath: initialDocCArchivePath)
12885 if potentialFrameworkName == nil {
12986 potentialFrameworkName = try findFrameworkName ( initialPath: newerDocCArchivePath)
13087 }
131-
132- if potentialFrameworkName != nil {
133- frameworkName = potentialFrameworkName ?? " No_Framework_Name "
134- }
88+ let frameworkName : String = potentialFrameworkName ?? " No_Framework_Name "
13589
13690 let additionLinks = groupSymbols ( symbolLinks: additionsToNewSet, frameworkName: frameworkName)
13791 let removalLinks = groupSymbols ( symbolLinks: removedFromOldSet, frameworkName: frameworkName)
13892
13993 // Create markdown file with changes in the newer DocC Archive that do not exist in the initial DocC Archive.
140- for fileNameAndContent in Docc . GenerateChangelog . changeLogTemplateFileContent ( frameworkName: frameworkName, initialDocCArchiveVersion: initialArchiveName, newerDocCArchiveVersion: newerArchiveName, additionLinks: additionLinks, removalLinks: removalLinks) {
94+ for fileNameAndContent in CatalogTemplateKind . changeLogTemplateFileContent ( frameworkName: frameworkName, initialDocCArchiveVersion: initialArchiveName, newerDocCArchiveVersion: newerArchiveName, additionLinks: additionLinks, removalLinks: removalLinks) {
14195 let fileName = fileNameAndContent. key
14296 let content = fileNameAndContent. value
14397 let filePath = initialDocCArchivePath. deletingLastPathComponent ( ) . appendingPathComponent ( fileName)
14498 try FileManager . default. createFile ( at: filePath, contents: Data ( content. utf8) )
14599 print ( " \n Output file path: \( filePath) " )
146100 }
147101 }
148-
149102
150103 /// Pretty print all symbols' url identifiers into a pretty format, with a new line between each symbol.
151104 func printAllSymbols( symbols: [ URL ] ) {
@@ -154,7 +107,6 @@ extension Docc {
154107 }
155108 }
156109
157-
158110 /// The framework name is the path component after "/documentation/".
159111 func findFrameworkName( initialPath: URL ) throws -> String ? {
160112 guard let enumerator = FileManager . default. enumerator (
0 commit comments