Skip to content

Commit c4bdf0b

Browse files
committed
Remove redundant "bundle" parameter from ConvertActionConverter
1 parent 8bfd711 commit c4bdf0b

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@ package enum ConvertActionConverter {
2121
static package let signposter = NoOpSignposterShim()
2222
#endif
2323

24-
/// Converts the documentation bundle in the given context and passes its output to a given consumer.
24+
/// Converts the documentation in the given context and passes its output to a given consumer.
2525
///
2626
/// - Parameters:
27-
/// - bundle: The documentation bundle to convert.
2827
/// - context: The context that the bundle is a part of.
2928
/// - outputConsumer: The consumer that the conversion passes outputs of the conversion to.
3029
/// - sourceRepository: The source repository where the documentation's sources are hosted.
3130
/// - emitDigest: Whether the conversion should pass additional metadata output––such as linkable entities information, indexing information, or asset references by asset type––to the consumer.
3231
/// - documentationCoverageOptions: The level of experimental documentation coverage information that the conversion should pass to the consumer.
3332
/// - Returns: A list of problems that occurred during the conversion (excluding the problems that the context already encountered).
3433
package static func convert(
35-
bundle: DocumentationBundle,
3634
context: DocumentationContext,
3735
outputConsumer: some ConvertOutputConsumer & ExternalNodeConsumer,
3836
sourceRepository: SourceRepository?,
@@ -66,7 +64,7 @@ package enum ConvertActionConverter {
6664
try outputConsumer.consume(renderReferenceStore: renderContext.store)
6765

6866
// Copy images, sample files, and other static assets.
69-
try outputConsumer.consume(assetsInBundle: bundle)
67+
try outputConsumer.consume(assetsInBundle: context.inputs)
7068

7169
let converter = DocumentationContextConverter(
7270
context: context,
@@ -108,7 +106,7 @@ package enum ConvertActionConverter {
108106
// Here we're associating the external node with the **current** bundle's bundle ID.
109107
// This is needed because nodes are only considered children if the parent and child's bundle ID match.
110108
// Otherwise, the node will be considered as a separate root node and displayed separately.
111-
let externalRenderNode = ExternalRenderNode(externalEntity: externalLink.value, bundleIdentifier: bundle.id)
109+
let externalRenderNode = ExternalRenderNode(externalEntity: externalLink.value, bundleIdentifier: context.inputs.id)
112110
try outputConsumer.consume(externalRenderNode: externalRenderNode)
113111
}
114112

@@ -191,7 +189,7 @@ package enum ConvertActionConverter {
191189
if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled {
192190
signposter.withIntervalSignpost("Serialize link hierarchy", id: signposter.makeSignpostID()) {
193191
do {
194-
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id)
192+
let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: context.inputs.id)
195193
try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation)
196194

197195
if !emitDigest {
@@ -224,7 +222,7 @@ package enum ConvertActionConverter {
224222
break
225223
}
226224

227-
try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleID: bundle.id))
225+
try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: context.inputs.displayName, bundleID: context.inputs.id))
228226

229227
// Log the finalized topic graph checksum.
230228
benchmark(add: Benchmark.TopicGraphHash(context: context))

Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ public struct ConvertAction: AsyncAction {
178178

179179
self.configuration = configuration
180180

181-
self.bundle = bundle
181+
self.inputs = bundle
182182
self.dataProvider = dataProvider
183183
}
184184

185185
let configuration: DocumentationContext.Configuration
186-
private let bundle: DocumentationBundle
186+
private let inputs: DocumentationBundle
187187
private let dataProvider: any DataProvider
188188

189189
/// A block of extra work that tests perform to affect the time it takes to convert documentation
@@ -286,10 +286,10 @@ public struct ConvertAction: AsyncAction {
286286
workingDirectory: temporaryFolder,
287287
fileManager: fileManager)
288288

289-
let indexer = try Indexer(outputURL: temporaryFolder, bundleID: bundle.id)
289+
let indexer = try Indexer(outputURL: temporaryFolder, bundleID: inputs.id)
290290

291291
let registerInterval = signposter.beginInterval("Register", id: signposter.makeSignpostID())
292-
let context = try await DocumentationContext(bundle: bundle, dataProvider: dataProvider, diagnosticEngine: diagnosticEngine, configuration: configuration)
292+
let context = try await DocumentationContext(bundle: inputs, dataProvider: dataProvider, diagnosticEngine: diagnosticEngine, configuration: configuration)
293293
signposter.endInterval("Register", registerInterval)
294294

295295
let outputConsumer = ConvertFileWritingConsumer(
@@ -300,7 +300,7 @@ public struct ConvertAction: AsyncAction {
300300
indexer: indexer,
301301
enableCustomTemplates: experimentalEnableCustomTemplates,
302302
transformForStaticHostingIndexHTML: transformForStaticHosting ? indexHTML : nil,
303-
bundleID: bundle.id
303+
bundleID: inputs.id
304304
)
305305

306306
if experimentalModifyCatalogWithGeneratedCuration, let catalogURL = rootURL {
@@ -318,7 +318,6 @@ public struct ConvertAction: AsyncAction {
318318
do {
319319
conversionProblems = try signposter.withIntervalSignpost("Process") {
320320
try ConvertActionConverter.convert(
321-
bundle: bundle,
322321
context: context,
323322
outputConsumer: outputConsumer,
324323
sourceRepository: sourceRepository,
@@ -347,7 +346,7 @@ public struct ConvertAction: AsyncAction {
347346
let tableOfContentsFilename = CatalogTemplateKind.tutorialTopLevelFilename
348347
let source = rootURL?.appendingPathComponent(tableOfContentsFilename)
349348
var replacements = [Replacement]()
350-
if let tableOfContentsTemplate = CatalogTemplateKind.tutorialTemplateFiles(bundle.displayName)[tableOfContentsFilename] {
349+
if let tableOfContentsTemplate = CatalogTemplateKind.tutorialTemplateFiles(inputs.displayName)[tableOfContentsFilename] {
351350
replacements.append(
352351
Replacement(
353352
range: .init(line: 1, column: 1, source: source) ..< .init(line: 1, column: 1, source: source),
@@ -438,7 +437,7 @@ public struct ConvertAction: AsyncAction {
438437
context: context,
439438
indexer: nil,
440439
transformForStaticHostingIndexHTML: nil,
441-
bundleID: bundle.id
440+
bundleID: inputs.id
442441
)
443442

444443
try outputConsumer.consume(benchmarks: Benchmark.main)

Tests/SwiftDocCTests/DeprecatedDiagnosticsDigestWarningTests.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ class DeprecatedDiagnosticsDigestWarningTests: XCTestCase {
2323
An empty root page
2424
""")
2525
])
26-
let (bundle, context) = try await loadBundle(catalog: catalog)
27-
26+
let (_, context) = try await loadBundle(catalog: catalog)
2827
let outputConsumer = TestOutputConsumer()
2928

3029
_ = try ConvertActionConverter.convert(
31-
bundle: bundle,
3230
context: context,
3331
outputConsumer: outputConsumer,
3432
sourceRepository: nil,
@@ -49,12 +47,10 @@ class DeprecatedDiagnosticsDigestWarningTests: XCTestCase {
4947
This link will result in a warning: ``NotFound``.
5048
""")
5149
])
52-
let (bundle, context) = try await loadBundle(catalog: catalog)
53-
50+
let (_, context) = try await loadBundle(catalog: catalog)
5451
let outputConsumer = TestOutputConsumer()
5552

5653
_ = try ConvertActionConverter.convert(
57-
bundle: bundle,
5854
context: context,
5955
outputConsumer: outputConsumer,
6056
sourceRepository: nil,

Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,13 @@ extension XCTestCase {
8989
sourceRepository: SourceRepository? = nil,
9090
configureBundle: ((URL) throws -> Void)? = nil
9191
) async throws -> TestRenderNodeOutputConsumer {
92-
let (_, bundle, context) = try await testBundleAndContext(
92+
let (_, _, context) = try await testBundleAndContext(
9393
copying: bundleName,
9494
configureBundle: configureBundle
9595
)
96-
9796
let outputConsumer = TestRenderNodeOutputConsumer()
9897

9998
_ = try ConvertActionConverter.convert(
100-
bundle: bundle,
10199
context: context,
102100
outputConsumer: outputConsumer,
103101
sourceRepository: sourceRepository,

Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,13 @@ class MergeActionTests: XCTestCase {
876876
try fileSystem.createDirectory(at: catalogDir, withIntermediateDirectories: true)
877877
try fileSystem.addFolder(catalog, basePath: catalogDir.deletingLastPathComponent())
878878

879-
let (bundle, dataProvider) = try DocumentationContext.InputsProvider(fileManager: fileSystem)
879+
let (inputs, dataProvider) = try DocumentationContext.InputsProvider(fileManager: fileSystem)
880880
.inputsAndDataProvider(startingPoint: catalogDir, options: .init())
881-
XCTAssertEqual(bundle.miscResourceURLs.map(\.lastPathComponent), [
881+
XCTAssertEqual(inputs.miscResourceURLs.map(\.lastPathComponent), [
882882
"\(name.lowercased())-card.png",
883883
])
884884

885-
let context = try await DocumentationContext(bundle: bundle, dataProvider: dataProvider, configuration: .init())
885+
let context = try await DocumentationContext(bundle: inputs, dataProvider: dataProvider, configuration: .init())
886886

887887
XCTAssert(
888888
context.problems.filter { $0.diagnostic.identifier != "org.swift.docc.SummaryContainsLink" }.isEmpty,
@@ -893,11 +893,11 @@ class MergeActionTests: XCTestCase {
893893
let outputPath = baseOutputDir.appendingPathComponent("\(name).doccarchive", isDirectory: true)
894894

895895
let realTempURL = try createTemporaryDirectory() // The navigator builder only support real file systems
896-
let indexer = try ConvertAction.Indexer(outputURL: realTempURL, bundleID: bundle.id)
896+
let indexer = try ConvertAction.Indexer(outputURL: realTempURL, bundleID: inputs.id)
897897

898-
let outputConsumer = ConvertFileWritingConsumer(targetFolder: outputPath, bundleRootFolder: catalogDir, fileManager: fileSystem, context: context, indexer: indexer, transformForStaticHostingIndexHTML: nil, bundleID: bundle.id)
898+
let outputConsumer = ConvertFileWritingConsumer(targetFolder: outputPath, bundleRootFolder: catalogDir, fileManager: fileSystem, context: context, indexer: indexer, transformForStaticHostingIndexHTML: nil, bundleID: inputs.id)
899899

900-
let convertProblems = try ConvertActionConverter.convert(bundle: bundle, context: context, outputConsumer: outputConsumer, sourceRepository: nil, emitDigest: false, documentationCoverageOptions: .noCoverage)
900+
let convertProblems = try ConvertActionConverter.convert(context: context, outputConsumer: outputConsumer, sourceRepository: nil, emitDigest: false, documentationCoverageOptions: .noCoverage)
901901
XCTAssert(convertProblems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))", file: file, line: line)
902902

903903
let navigatorProblems = indexer.finalize(emitJSON: true, emitLMDB: false)

0 commit comments

Comments
 (0)