Skip to content

Commit 043ba3b

Browse files
committed
List all the generated documentation archvies
1 parent b623ee6 commit 043ba3b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Plugins/Swift-DocC Convert/SwiftDocCConvert.swift

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import PackagePlugin
5757
#endif
5858

5959
// 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? {
6161
let target = task.target
6262
print("Generating documentation for '\(target.name)'...")
6363

@@ -86,7 +86,7 @@ import PackagePlugin
8686
// This is the only target being built so emit an error
8787
Diagnostics.error(message)
8888
}
89-
return
89+
return nil
9090
}
9191

9292
// Construct the output path for the generated DocC archive
@@ -133,6 +133,7 @@ import PackagePlugin
133133
Diagnostics.error("'docc convert' invocation failed with a nonzero exit code: '\(process.terminationStatus)'")
134134
}
135135

136+
return URL(fileURLWithPath: doccArchiveOutputPath)
136137
}
137138

138139
// Create a build graph for all the documentation build tasks.
@@ -143,14 +144,19 @@ import PackagePlugin
143144

144145
// Operations can't raise errors. Instead we catch the error from 'performBuildTask(_:)'
145146
// and cancel the remaining tasks.
146-
let errorLock = NSLock()
147+
let resultLock = NSLock()
147148
var caughtError: Error?
149+
var documentationArchives: [URL] = []
148150

149151
let operations = buildGraph.makeOperations { [performBuildTask] task in
150152
do {
151-
try performBuildTask(task)
153+
if let archive = try performBuildTask(task) {
154+
resultLock.withLock {
155+
documentationArchives.append(archive)
156+
}
157+
}
152158
} catch {
153-
errorLock.withLock {
159+
resultLock.withLock {
154160
caughtError = error
155161
queue.cancelAllOperations()
156162
}
@@ -163,9 +169,12 @@ import PackagePlugin
163169

164170
// Run all the documentation build tasks in reverse dependency order (dependencies before dependents).
165171
queue.addOperations(operations, waitUntilFinished: true)
166-
167-
if swiftSourceModuleTargets.count > 1 {
168-
print("\nMultiple 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+
""")
169178
}
170179
}
171180
}

0 commit comments

Comments
 (0)