@@ -16,56 +16,14 @@ extension Docc {
16
16
17
17
struct GenerateChangelog : ParsableCommand {
18
18
19
- // MARK: - Content and Configuration
19
+ // MARK: - Configuration
20
20
21
21
/// Command line configuration.
22
22
static var configuration = CommandConfiguration (
23
23
commandName: " generate-changelog " ,
24
24
abstract: " Generate a changelog with symbol diffs between documentation archives ('.doccarchive' directories). " ,
25
25
shouldDisplay: true )
26
26
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
-
69
27
70
28
// MARK: - Command Line Options & Arguments
71
29
@@ -115,37 +73,32 @@ extension Docc {
115
73
print ( " Showing ONLY high-level symbol diffs: modules, classes, protocols, and structs. " )
116
74
}
117
75
118
- let initialSet = Set ( initialDocCArchiveAPIs. map { $0 } )
119
- let newSet = Set ( newDocCArchiveAPIs. map { $0 } )
76
+ let initialSet = Set ( initialDocCArchiveAPIs)
77
+ let newSet = Set ( newDocCArchiveAPIs)
120
78
121
79
// Compute additions and removals to both sets
122
80
let additionsToNewSet = newSet. subtracting ( initialSet)
123
81
let removedFromOldSet = initialSet. subtracting ( newSet)
124
82
125
83
// The framework name is the path component after "/documentation/".
126
- var frameworkName : String = " No_Framework_Name "
127
84
var potentialFrameworkName = try findFrameworkName ( initialPath: initialDocCArchivePath)
128
85
if potentialFrameworkName == nil {
129
86
potentialFrameworkName = try findFrameworkName ( initialPath: newerDocCArchivePath)
130
87
}
131
-
132
- if potentialFrameworkName != nil {
133
- frameworkName = potentialFrameworkName ?? " No_Framework_Name "
134
- }
88
+ let frameworkName : String = potentialFrameworkName ?? " No_Framework_Name "
135
89
136
90
let additionLinks = groupSymbols ( symbolLinks: additionsToNewSet, frameworkName: frameworkName)
137
91
let removalLinks = groupSymbols ( symbolLinks: removedFromOldSet, frameworkName: frameworkName)
138
92
139
93
// 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) {
141
95
let fileName = fileNameAndContent. key
142
96
let content = fileNameAndContent. value
143
97
let filePath = initialDocCArchivePath. deletingLastPathComponent ( ) . appendingPathComponent ( fileName)
144
98
try FileManager . default. createFile ( at: filePath, contents: Data ( content. utf8) )
145
99
print ( " \n Output file path: \( filePath) " )
146
100
}
147
101
}
148
-
149
102
150
103
/// Pretty print all symbols' url identifiers into a pretty format, with a new line between each symbol.
151
104
func printAllSymbols( symbols: [ URL ] ) {
@@ -154,7 +107,6 @@ extension Docc {
154
107
}
155
108
}
156
109
157
-
158
110
/// The framework name is the path component after "/documentation/".
159
111
func findFrameworkName( initialPath: URL ) throws -> String ? {
160
112
guard let enumerator = FileManager . default. enumerator (
0 commit comments