Skip to content

Commit faaa649

Browse files
committed
Remove redundant "bundle" parameter from DocumentationCurator
1 parent a657d32 commit faaa649

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ public class DocumentationContext {
24572457
signposter.endInterval("Curate symbols", signpostHandle)
24582458
}
24592459

2460-
var crawler = DocumentationCurator(in: self, bundle: bundle, initial: initial)
2460+
var crawler = DocumentationCurator(in: self, initial: initial)
24612461

24622462
for reference in references {
24632463
try crawler.crawlChildren(

Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -17,14 +17,10 @@ struct DocumentationCurator {
1717
/// The documentation context to crawl.
1818
private let context: DocumentationContext
1919

20-
/// The current bundle.
21-
private let bundle: DocumentationBundle
22-
2320
private(set) var problems = [Problem]()
2421

25-
init(in context: DocumentationContext, bundle: DocumentationBundle, initial: Set<ResolvedTopicReference> = []) {
22+
init(in context: DocumentationContext, initial: Set<ResolvedTopicReference> = []) {
2623
self.context = context
27-
self.bundle = bundle
2824
self.curatedNodes = initial
2925
}
3026

@@ -99,7 +95,7 @@ struct DocumentationCurator {
9995
// - "documentation/CatalogName/ArticleName"
10096
switch path.components(separatedBy: "/").count {
10197
case 0,1:
102-
return NodeURLGenerator.Path.article(bundleName: bundle.displayName, articleName: path).stringValue
98+
return NodeURLGenerator.Path.article(bundleName: context.inputs.displayName, articleName: path).stringValue
10399
case 2:
104100
return "\(NodeURLGenerator.Path.documentationFolder)/\(path)"
105101
default:

Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class DocumentationCuratorTests: XCTestCase {
2828
}
2929

3030
func testCrawl() async throws {
31-
let (bundle, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
31+
let (_, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
3232

33-
var crawler = DocumentationCurator(in: context, bundle: bundle)
33+
var crawler = DocumentationCurator(in: context)
3434
let mykit = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))
3535

3636
var symbolsWithCustomCuration = [ResolvedTopicReference]()
@@ -75,7 +75,7 @@ class DocumentationCuratorTests: XCTestCase {
7575
}
7676

7777
func testCrawlDiagnostics() async throws {
78-
let (tempCatalogURL, bundle, context) = try await testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in
78+
let (tempCatalogURL, _, context) = try await testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in
7979
let extensionFile = url.appendingPathComponent("documentation/myfunction.md")
8080

8181
try """
@@ -97,7 +97,7 @@ class DocumentationCuratorTests: XCTestCase {
9797
}
9898
let extensionFile = tempCatalogURL.appendingPathComponent("documentation/myfunction.md")
9999

100-
var crawler = DocumentationCurator(in: context, bundle: bundle)
100+
var crawler = DocumentationCurator(in: context)
101101
let mykit = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))
102102

103103
XCTAssertNoThrow(try crawler.crawlChildren(of: mykit.reference, prepareForCuration: { _ in }, relateNodes: { _, _ in }))
@@ -286,7 +286,7 @@ class DocumentationCuratorTests: XCTestCase {
286286
}
287287

288288
func testModuleUnderTechnologyRoot() async throws {
289-
let (_, bundle, context) = try await testBundleAndContext(copying: "SourceLocations") { url in
289+
let (_, _, context) = try await testBundleAndContext(copying: "SourceLocations") { url in
290290
try """
291291
# Root curating a module
292292
@@ -303,7 +303,7 @@ class DocumentationCuratorTests: XCTestCase {
303303
""".write(to: url.appendingPathComponent("Root.md"), atomically: true, encoding: .utf8)
304304
}
305305

306-
let crawler = DocumentationCurator(in: context, bundle: bundle)
306+
let crawler = DocumentationCurator(in: context)
307307
XCTAssert(context.problems.isEmpty, "Expected no problems. Found: \(context.problems.map(\.diagnostic.summary))")
308308

309309
guard let moduleNode = context.documentationCache["SourceLocations"],
@@ -459,9 +459,9 @@ class DocumentationCuratorTests: XCTestCase {
459459
}
460460

461461
func testSymbolLinkResolving() async throws {
462-
let (bundle, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
462+
let (_, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
463463

464-
let crawler = DocumentationCurator(in: context, bundle: bundle)
464+
let crawler = DocumentationCurator(in: context)
465465

466466
// Resolve top-level symbol in module parent
467467
do {
@@ -512,9 +512,9 @@ class DocumentationCuratorTests: XCTestCase {
512512
}
513513

514514
func testLinkResolving() async throws {
515-
let (sourceRoot, bundle, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
515+
let (sourceRoot, _, context) = try await testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests")
516516

517-
var crawler = DocumentationCurator(in: context, bundle: bundle)
517+
var crawler = DocumentationCurator(in: context)
518518

519519
// Resolve and curate an article in module root (absolute link)
520520
do {
@@ -567,7 +567,7 @@ class DocumentationCuratorTests: XCTestCase {
567567
}
568568

569569
func testGroupLinkValidation() async throws {
570-
let (_, bundle, context) = try await testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { root in
570+
let (_, _, context) = try await testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { root in
571571
// Create a sidecar with invalid group links
572572
try! """
573573
# ``SideKit``
@@ -607,7 +607,7 @@ class DocumentationCuratorTests: XCTestCase {
607607
""".write(to: root.appendingPathComponent("documentation").appendingPathComponent("api-collection.md"), atomically: true, encoding: .utf8)
608608
}
609609

610-
var crawler = DocumentationCurator(in: context, bundle: bundle)
610+
var crawler = DocumentationCurator(in: context)
611611
let reference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)
612612

613613
try crawler.crawlChildren(of: reference, prepareForCuration: {_ in }) { (_, _) in }

0 commit comments

Comments
 (0)