@@ -57,7 +57,7 @@ import PackagePlugin
57
57
#endif
58
58
59
59
// An inner function that defines the work to build documentation for a given target.
60
- func performBuildTask( _ task: DocumentationBuildGraph < SwiftSourceModuleTarget > . Task ) throws {
60
+ func performBuildTask( _ task: DocumentationBuildGraph < SwiftSourceModuleTarget > . Task ) throws -> URL ? {
61
61
let target = task. target
62
62
print ( " Generating documentation for ' \( target. name) '... " )
63
63
@@ -86,7 +86,7 @@ import PackagePlugin
86
86
// This is the only target being built so emit an error
87
87
Diagnostics . error ( message)
88
88
}
89
- return
89
+ return nil
90
90
}
91
91
92
92
// Construct the output path for the generated DocC archive
@@ -133,6 +133,7 @@ import PackagePlugin
133
133
Diagnostics . error ( " 'docc convert' invocation failed with a nonzero exit code: ' \( process. terminationStatus) ' " )
134
134
}
135
135
136
+ return URL ( fileURLWithPath: doccArchiveOutputPath)
136
137
}
137
138
138
139
// Create a build graph for all the documentation build tasks.
@@ -143,14 +144,19 @@ import PackagePlugin
143
144
144
145
// Operations can't raise errors. Instead we catch the error from 'performBuildTask(_:)'
145
146
// and cancel the remaining tasks.
146
- let errorLock = NSLock ( )
147
+ let resultLock = NSLock ( )
147
148
var caughtError : Error ?
149
+ var documentationArchives : [ URL ] = [ ]
148
150
149
151
let operations = buildGraph. makeOperations { [ performBuildTask] task in
150
152
do {
151
- try performBuildTask ( task)
153
+ if let archive = try performBuildTask ( task) {
154
+ resultLock. withLock {
155
+ documentationArchives. append ( archive)
156
+ }
157
+ }
152
158
} catch {
153
- errorLock . withLock {
159
+ resultLock . withLock {
154
160
caughtError = error
155
161
queue. cancelAllOperations ( )
156
162
}
@@ -163,9 +169,12 @@ import PackagePlugin
163
169
164
170
// Run all the documentation build tasks in reverse dependency order (dependencies before dependents).
165
171
queue. addOperations ( operations, waitUntilFinished: true )
166
-
167
- if swiftSourceModuleTargets. count > 1 {
168
- print ( " \n Multiple DocC archives generated at ' \( context. pluginWorkDirectory. string) ' " )
172
+
173
+ if documentationArchives. count > 1 {
174
+ print ( """
175
+ Generated \( documentationArchives. count) DocC archives in ' \( context. pluginWorkDirectory. string) ':
176
+ \( documentationArchives. map ( \. lastPathComponent) . sorted ( ) . joined ( separator: " \n " ) )
177
+ """ )
169
178
}
170
179
}
171
180
}
0 commit comments