From 28b9522510a32e9e8e11e7a79555eaf6d432f37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 13:16:54 +0200 Subject: [PATCH 01/17] Add bundle identifier type that ensures a valid URL host component rdar://135335645 --- .../DocumentationBundle+Identifier.swift | 67 +++++++++++++++++++ .../DocumentationBundleIdentifierTests.swift | 59 ++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 Sources/SwiftDocC/Infrastructure/DocumentationBundle+Identifier.swift create mode 100644 Tests/SwiftDocCTests/Infrastructure/DocumentationBundleIdentifierTests.swift diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationBundle+Identifier.swift b/Sources/SwiftDocC/Infrastructure/DocumentationBundle+Identifier.swift new file mode 100644 index 000000000..2a81d44bb --- /dev/null +++ b/Sources/SwiftDocC/Infrastructure/DocumentationBundle+Identifier.swift @@ -0,0 +1,67 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2024 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See https://swift.org/LICENSE.txt for license information + See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +import Foundation + +extension DocumentationBundle { + /// A stable and locally unique identifier for a collection of documentation inputs. + public struct Identifier: RawRepresentable { + public let rawValue: String + + public init(rawValue: String) { + // To ensure that the identifier can be used as a valid "host" component of a resolved topic reference's url, + // replace any consecutive sequence of unsupported characters with a "-". + self.rawValue = rawValue + .components(separatedBy: Self.charactersToReplace) + .filter { !$0.isEmpty } + .joined(separator: "-") + } + + private static let charactersToReplace = CharacterSet.urlHostAllowed.inverted + } +} + +extension DocumentationBundle.Identifier: Hashable {} +extension DocumentationBundle.Identifier: Sendable {} + +// Support creating an identifier from a string literal. +extension DocumentationBundle.Identifier: ExpressibleByStringLiteral { + public init(stringLiteral value: StringLiteralType) { + self.init(rawValue: value) + } +} + +// Sort identifiers based on their raw string value. +extension DocumentationBundle.Identifier: Comparable { + public static func < (lhs: Self, rhs: Self) -> Bool { + lhs.rawValue < rhs.rawValue + } +} + +// Print as a single string value +extension DocumentationBundle.Identifier: CustomStringConvertible { + public var description: String { + rawValue + } +} + +// Encode and decode the identifier as a single string value. +extension DocumentationBundle.Identifier: Codable { + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let rawValue = try container.decode(String.self) + self.init(rawValue: rawValue) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValue) + } +} diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleIdentifierTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleIdentifierTests.swift new file mode 100644 index 000000000..160406e6f --- /dev/null +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleIdentifierTests.swift @@ -0,0 +1,59 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2024 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See https://swift.org/LICENSE.txt for license information + See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +import XCTest +@testable import SwiftDocC + +class DocumentationBundleIdentifierTests: XCTestCase { + private typealias Identifier = DocumentationBundle.Identifier + + func testInitialization() { + let id = Identifier(rawValue: "com.example.test") + XCTAssertEqual(id.rawValue, "com.example.test") + + let idWithSpace = Identifier(rawValue: "Package Name") + XCTAssertEqual(idWithSpace.rawValue, "Package-Name", "The initializer transforms the value to a valid identifier") + } + + func testExpressibleByStringLiteral() { + let id: Identifier = "com.example.test" + XCTAssertEqual(id.rawValue, "com.example.test") + + let idWithSpace: Identifier = "Package Name" + XCTAssertEqual(idWithSpace.rawValue, "Package-Name", "The initializer transforms the value to a valid identifier") + } + + func testEquatable() { + XCTAssertEqual(Identifier(rawValue: "A"), "A") + XCTAssertNotEqual(Identifier(rawValue: "A"), "B") + } + + func testComparable() { + XCTAssertLessThan(Identifier(rawValue: "B"), "C") + XCTAssertGreaterThan(Identifier(rawValue: "B"), "A") + } + + func testCustomStringConvertible() { + XCTAssertEqual(Identifier(rawValue: "com.example.test").description, "com.example.test") + XCTAssertEqual(Identifier(rawValue: "Package Name").description, "Package-Name") + + } + + func testEncodesAsPlainString() throws { + let id = Identifier(rawValue: "com.example.test") + let encoded = try String(data: JSONEncoder().encode(id), encoding: .utf8) + XCTAssertEqual(encoded, "\"com.example.test\"") + } + + func testDecodingFromPlainString() throws { + let decoded = try JSONDecoder().decode(Identifier.self, from: Data("\"com.example.test\"".utf8)) + XCTAssertEqual(decoded, "com.example.test") + } +} From 0e62ffcb560da6bac949a0ff4a231933cd93585a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 13:23:57 +0200 Subject: [PATCH 02/17] Use new Identifier type in `DocumentationBundle/Info` --- .../Workspace/DocumentationBundle+Info.swift | 57 +++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/Workspace/DocumentationBundle+Info.swift b/Sources/SwiftDocC/Infrastructure/Workspace/DocumentationBundle+Info.swift index 35dd5ae68..b6eb5d272 100644 --- a/Sources/SwiftDocC/Infrastructure/Workspace/DocumentationBundle+Info.swift +++ b/Sources/SwiftDocC/Infrastructure/Workspace/DocumentationBundle+Info.swift @@ -18,8 +18,13 @@ extension DocumentationBundle { /// The display name of the bundle. public var displayName: String + @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") + public var identifier: String { + id.rawValue + } + /// The unique identifier of the bundle. - public var identifier: String + public var id: DocumentationBundle.Identifier /// The version of the bundle. @available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released") @@ -38,11 +43,11 @@ extension DocumentationBundle { internal var featureFlags: BundleFeatureFlags? /// The keys that must be present in an Info.plist file in order for doc compilation to proceed. - static let requiredKeys: Set = [.displayName, .identifier] + static let requiredKeys: Set = [.displayName, .id] enum CodingKeys: String, CodingKey, CaseIterable { case displayName = "CFBundleDisplayName" - case identifier = "CFBundleIdentifier" + case id = "CFBundleIdentifier" case defaultCodeListingLanguage = "CDDefaultCodeListingLanguage" case defaultAvailability = "CDAppleDefaultAvailability" case defaultModuleKind = "CDDefaultModuleKind" @@ -52,7 +57,7 @@ extension DocumentationBundle { switch self { case .displayName: return "--fallback-display-name" - case .identifier: + case .id: return "--fallback-bundle-identifier" case .defaultCodeListingLanguage: return "--default-code-listing-language" @@ -83,10 +88,28 @@ extension DocumentationBundle { /// Creates a new documentation bundle information value. /// - Parameters: /// - displayName: The display name of the bundle. - /// - identifier: The unique identifier of the bundle. + /// - id: The unique identifier of the bundle. /// - defaultCodeListingLanguage: The default language identifier for code listings in the bundle. /// - defaultAvailability: The default availability for the various modules in the bundle. /// - defaultModuleKind: The default kind for the various modules in the bundle. + public init( + displayName: String, + id: DocumentationBundle.Identifier, + defaultCodeListingLanguage: String?, + defaultAvailability: DefaultAvailability?, + defaultModuleKind: String? + ) { + self.init( + displayName: displayName, + id: id, + defaultCodeListingLanguage: defaultCodeListingLanguage, + defaultModuleKind: defaultModuleKind, + defaultAvailability: defaultAvailability, + featureFlags: nil + ) + } + + @available(*, deprecated, renamed: "init(displayName:id:defaultCodeListingLanguage:defaultAvailability:defaultModuleKind:)", message: "Use 'Info.init(displayName:id:defaultCodeListingLanguage:defaultAvailability:defaultModuleKind:)' instead. This deprecated API will be removed after 6.2 is released") public init( displayName: String, identifier: String, @@ -94,11 +117,13 @@ extension DocumentationBundle { defaultAvailability: DefaultAvailability?, defaultModuleKind: String? ) { - self.displayName = displayName - self.identifier = identifier - self.defaultCodeListingLanguage = defaultCodeListingLanguage - self.defaultAvailability = defaultAvailability - self.defaultModuleKind = defaultModuleKind + self.init( + displayName: displayName, + id: .init(rawValue: identifier), + defaultCodeListingLanguage: defaultCodeListingLanguage, + defaultAvailability: defaultAvailability, + defaultModuleKind: defaultModuleKind + ) } /// Creates documentation bundle information from the given Info.plist data, falling back to the values @@ -199,13 +224,13 @@ extension DocumentationBundle { // If present, we can use `Info.displayName` as a fallback // for `Info.identifier`. if givenKeys.contains(.displayName) { - givenKeys.insert(.identifier) + givenKeys.insert(.id) } // If present, we can use the `derivedDisplayName` // as a fallback for the `Info.displayName` and `Info.identifier`. if derivedDisplayName != nil { - givenKeys.formUnion([.displayName, .identifier]) + givenKeys.formUnion([.displayName, .id]) } let missingKeys = Self.requiredKeys.subtracting(givenKeys) @@ -221,7 +246,7 @@ extension DocumentationBundle { // It's safe to unwrap `derivedDisplayName` because it will only be accessed if neither the decoding container nor the bundle discovery options // contain a display name. If they do but that value fails to decode, that error would be raised before accessing `derivedDisplayName`. self.displayName = try decodeOrFallbackIfPresent(String.self, with: .displayName) ?? derivedDisplayName! - self.identifier = try decodeOrFallbackIfPresent(String.self, with: .identifier) ?? self.displayName + self.id = try decodeOrFallbackIfPresent(Identifier.self, with: .id) ?? .init(rawValue: self.displayName) // Finally, decode the optional keys if they're present. @@ -233,14 +258,14 @@ extension DocumentationBundle { init( displayName: String, - identifier: String, + id: DocumentationBundle.Identifier, defaultCodeListingLanguage: String? = nil, defaultModuleKind: String? = nil, defaultAvailability: DefaultAvailability? = nil, featureFlags: BundleFeatureFlags? = nil ) { self.displayName = displayName - self.identifier = identifier + self.id = id self.defaultCodeListingLanguage = defaultCodeListingLanguage self.defaultModuleKind = defaultModuleKind self.defaultAvailability = defaultAvailability @@ -281,7 +306,7 @@ extension BundleDiscoveryOptions { switch key { case .displayName: value = fallbackDisplayName - case .identifier: + case .id: value = fallbackIdentifier case .defaultCodeListingLanguage: value = fallbackDefaultCodeListingLanguage From b46b5d3eddce2aab6e10379307a32b7d356ee53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 13:40:02 +0200 Subject: [PATCH 03/17] Update code to not use deprecated `Info/identifier` property --- .../Convert/ConvertService.swift | 2 +- .../Infrastructure/DocumentationBundle.swift | 8 ++--- .../OutOfProcessReferenceResolver.swift | 30 +++++++++++++------ .../Actions/Convert/ConvertAction.swift | 2 +- .../ConvertService/ConvertServiceTests.swift | 16 +++++----- .../DocumentationServer+DefaultTests.swift | 2 +- .../DocumentationBundleInfoTests.swift | 20 ++++++------- .../DocumentationWorkspaceTests.swift | 2 +- .../SymbolDisambiguationTests.swift | 2 +- .../SymbolGraph/SymbolGraphLoaderTests.swift | 2 +- .../DefaultCodeListingSyntaxTests.swift | 2 +- .../XCTestCase+LoadingTestData.swift | 2 +- 12 files changed, 51 insertions(+), 39 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift index 4904fa6ac..10fcba85f 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift @@ -128,7 +128,7 @@ public struct ConvertService: DocumentationService { if let linkResolvingServer { let resolver = try OutOfProcessReferenceResolver( - bundleIdentifier: request.bundleInfo.identifier, + id: request.bundleInfo.id, server: linkResolvingServer, convertRequestIdentifier: messageIdentifier ) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift index ce987274c..3e434ec5e 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift @@ -55,7 +55,7 @@ public struct DocumentationBundle { An identifier string that specifies the app type of the bundle. The string should be in reverse DNS format using only the Roman alphabet in upper and lower case (A–Z, a–z), the dot (“.”), and the hyphen (“-”). */ public var identifier: String { - info.identifier + info.id.rawValue } /** @@ -126,9 +126,9 @@ public struct DocumentationBundle { self.customHeader = customHeader self.customFooter = customFooter self.themeSettings = themeSettings - self.rootReference = ResolvedTopicReference(bundleIdentifier: info.identifier, path: "/", sourceLanguage: .swift) - self.documentationRootReference = ResolvedTopicReference(bundleIdentifier: info.identifier, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) - self.tutorialTableOfContentsContainer = ResolvedTopicReference(bundleIdentifier: info.identifier, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) + self.rootReference = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: "/", sourceLanguage: .swift) + self.documentationRootReference = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) + self.tutorialTableOfContentsContainer = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) self.tutorialsContainerReference = tutorialTableOfContentsContainer.appendingPath(urlReadablePath(info.displayName)) self.articlesDocumentationRootReference = documentationRootReference.appendingPath(urlReadablePath(info.displayName)) } diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index 25997a501..3141807d0 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -51,8 +51,13 @@ import SymbolKit public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalExternalSymbolResolver { private let externalLinkResolvingClient: ExternalLinkResolving + @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") + public var bundleIdentifier: String { + id.rawValue + } + /// The bundle identifier for the reference resolver in the other process. - public let bundleIdentifier: String + public let id: DocumentationBundle.Identifier /// Creates a new reference resolver that interacts with another executable. /// @@ -77,20 +82,27 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE throw Error.invalidBundleIdentifierOutputFromExecutable(processLocation) } - self.bundleIdentifier = decodedBundleIdentifier + self.id = .init(rawValue: decodedBundleIdentifier) self.externalLinkResolvingClient = longRunningProcess } + @available(*, deprecated, renamed: "init(id:server:convertRequestIdentifier:)", message: "Use 'init(id:server:convertRequestIdentifier:)' instead. This deprecated API will be removed after 6.2 is released") + public init(bundleIdentifier: String, server: DocumentationServer, convertRequestIdentifier: String?) throws { + self.id = .init(rawValue: bundleIdentifier) + self.externalLinkResolvingClient = LongRunningService( + server: server, convertRequestIdentifier: convertRequestIdentifier) + } + /// Creates a new reference resolver that interacts with a documentation service. /// /// The documentation service is expected to be able to handle messages of kind "resolve-reference". /// /// - Parameters: - /// - bundleIdentifier: The bundle identifier the server can resolve references for. + /// - id: The bundle identifier the server can resolve references for. /// - server: The server to send link resolution requests to. /// - convertRequestIdentifier: The identifier that the resolver will use for convert requests that it sends to the server. - public init(bundleIdentifier: String, server: DocumentationServer, convertRequestIdentifier: String?) throws { - self.bundleIdentifier = bundleIdentifier + public init(id: DocumentationBundle.Identifier, server: DocumentationServer, convertRequestIdentifier: String?) throws { + self.id = id self.externalLinkResolvingClient = LongRunningService( server: server, convertRequestIdentifier: convertRequestIdentifier) } @@ -103,7 +115,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE return resolved case let .unresolved(unresolvedReference): - guard unresolvedReference.bundleIdentifier == bundleIdentifier else { + guard unresolvedReference.bundleIdentifier == id.rawValue else { fatalError(""" Attempted to resolve a local reference externally: \(unresolvedReference.description.singleQuoted). DocC should never pass a reference to an external resolver unless it matches that resolver's bundle identifier. @@ -243,7 +255,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE private func resolvedReference(for resolvedInformation: ResolvedInformation) -> ResolvedTopicReference { return ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + bundleIdentifier: id.rawValue, path: resolvedInformation.url.path, fragment: resolvedInformation.url.fragment, sourceLanguages: sourceLanguages(for: resolvedInformation) @@ -767,13 +779,13 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { } func resolveInformationForAsset(named assetName: String) throws -> DataAsset { - let assetReference = AssetReference(assetName: assetName, bundleIdentifier: bundleIdentifier) + let assetReference = AssetReference(assetName: assetName, bundleIdentifier: id.rawValue) if let asset = assetCache[assetReference] { return asset } let response = try externalLinkResolvingClient.sendAndWait( - request: Request.asset(AssetReference(assetName: assetName, bundleIdentifier: bundleIdentifier)) + request: Request.asset(AssetReference(assetName: assetName, bundleIdentifier: id.rawValue)) ) as Response switch response { diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift index 7338e528b..717b58a1c 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift @@ -160,7 +160,7 @@ public struct ConvertAction: AsyncAction { } if let outOfProcessResolver { - configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.bundleIdentifier] = outOfProcessResolver + configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.id.rawValue] = outOfProcessResolver configuration.externalDocumentationConfiguration.globalSymbolResolver = outOfProcessResolver } configuration.externalDocumentationConfiguration.dependencyArchives = dependencies diff --git a/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift b/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift index dbc2e01de..2d9e7b3b5 100644 --- a/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift +++ b/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift @@ -17,7 +17,7 @@ import SwiftDocCTestUtilities class ConvertServiceTests: XCTestCase { private let testBundleInfo = DocumentationBundle.Info( displayName: "TestBundle", - identifier: "identifier" + id: "identifier" ) func testConvertSinglePage() throws { @@ -1730,7 +1730,7 @@ class ConvertServiceTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundle", - identifier: "com.test.bundle" + id: "com.test.bundle" ), externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"], documentPathsToConvert: [], @@ -2019,7 +2019,7 @@ class ConvertServiceTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundle", - identifier: "org.swift.example" + id: "org.swift.example" ), externalIDsToConvert: ["s:32MyKit3FooV"], documentPathsToConvert: [], @@ -2128,7 +2128,7 @@ class ConvertServiceTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundleDisplayName", - identifier: "com.test.bundle" + id: "com.test.bundle" ), externalIDsToConvert: ["s:21SmallTestingFramework40EnumerationWithSingleUnresolvableDocLinkO"], documentPathsToConvert: [], @@ -2166,7 +2166,7 @@ class ConvertServiceTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundleDisplayName", - identifier: "com.test.bundle" + id: "com.test.bundle" ), externalIDsToConvert: ["s:21SmallTestingFramework15TestEnumerationO06NesteddE0O0D6StructV06deeplyfD31FunctionWithUnresolvableDocLinkyyF"], documentPathsToConvert: [], @@ -2205,7 +2205,7 @@ class ConvertServiceTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundleDisplayName", - identifier: "com.test.bundle" + id: "com.test.bundle" ), externalIDsToConvert: ["s:21SmallTestingFramework43EnumerationWithSingleUnresolvableSymbolLinkO"], documentPathsToConvert: [], @@ -2331,7 +2331,7 @@ class ConvertServiceTests: XCTestCase { let bundleURL = tempURL.appendingPathComponent("unit-test.docc") let requestWithDifferentBundleID = ConvertRequest( - bundleInfo: DocumentationBundle.Info(displayName: "DisplayName", identifier: "com.example.something-else"), + bundleInfo: DocumentationBundle.Info(displayName: "DisplayName", id: "com.example.something-else"), externalIDsToConvert: [], bundleLocation: bundleURL, symbolGraphs: [], @@ -2341,7 +2341,7 @@ class ConvertServiceTests: XCTestCase { XCTAssertEqual(try linkResolutionRequestsForConvertRequest(requestWithDifferentBundleID), [], "Shouldn't make any link resolution requests because the bundle IDs are different.") let requestWithSameBundleID = ConvertRequest( - bundleInfo: DocumentationBundle.Info(displayName: "DisplayName", identifier: "com.example.something"), + bundleInfo: DocumentationBundle.Info(displayName: "DisplayName", id: "com.example.something"), externalIDsToConvert: [], bundleLocation: bundleURL, symbolGraphs: [], diff --git a/Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift b/Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift index 9488df747..6f4ddc2c6 100644 --- a/Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift +++ b/Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift @@ -68,7 +68,7 @@ class DocumentationServer_DefaultTests: XCTestCase { let request = ConvertRequest( bundleInfo: DocumentationBundle.Info( displayName: "TestBundle", - identifier: "identifier" + id: "identifier" ), externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"], symbolGraphs: [symbolGraph], diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift index 2e2461484..36acf8c0a 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift @@ -22,7 +22,7 @@ class DocumentationBundleInfoTests: XCTestCase { let info = try DocumentationBundle.Info(from: infoPlistData) XCTAssertEqual(info.displayName, "Test Bundle") - XCTAssertEqual(info.identifier, "org.swift.docc.example") + XCTAssertEqual(info.id.rawValue, "org.swift.docc.example") XCTAssertEqual(info.defaultCodeListingLanguage, "swift") } @@ -82,7 +82,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Info Plist Display Name", - identifier: "com.info.Plist" + id: "com.info.Plist" ) ) @@ -93,7 +93,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Fallback Display Name", - identifier: "com.fallback.Identifier" + id: "com.fallback.Identifier" ) ) @@ -104,7 +104,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Fallback Display Name", - identifier: "com.info.Plist" + id: "com.info.Plist" ) ) @@ -128,7 +128,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Info Plist Display Name", - identifier: "com.info.Plist" + id: "com.info.Plist" ) ) } @@ -237,7 +237,7 @@ class DocumentationBundleInfoTests: XCTestCase { info, DocumentationBundle.Info( displayName: "Display Name", - identifier: "swift.org.Identifier", + id: "swift.org.Identifier", defaultCodeListingLanguage: "swift", defaultModuleKind: "Executable", defaultAvailability: DefaultAvailability( @@ -257,7 +257,7 @@ class DocumentationBundleInfoTests: XCTestCase { func testFallbackToInfoInBundleDiscoveryOptions() throws { let info = DocumentationBundle.Info( displayName: "Display Name", - identifier: "swift.org.Identifier", + id: "swift.org.Identifier", defaultCodeListingLanguage: "swift", defaultModuleKind: "Executable", defaultAvailability: DefaultAvailability( @@ -341,7 +341,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Derived Display Name", - identifier: "Derived Display Name" + id: "Derived Display Name" ) ) } @@ -366,7 +366,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Derived Display Name", - identifier: "org.swift.docc.example" + id: "org.swift.docc.example" ) ) } @@ -390,7 +390,7 @@ class DocumentationBundleInfoTests: XCTestCase { ), DocumentationBundle.Info( displayName: "Example", - identifier: "Example" + id: "Example" ) ) } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationWorkspaceTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationWorkspaceTests.swift index 51b0d2bc6..b7e9347f6 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationWorkspaceTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationWorkspaceTests.swift @@ -151,7 +151,7 @@ class DocumentationWorkspaceTests: XCTestCase { return DocumentationBundle( info: DocumentationBundle.Info( displayName: "Test" + suffix, - identifier: "com.example.test" + suffix + id: DocumentationBundle.Identifier(rawValue: "com.example.test" + suffix) ), symbolGraphURLs: [testSymbolGraphFile], markupURLs: [testMarkupFile], diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolDisambiguationTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolDisambiguationTests.swift index 87dd835ce..b838e9066 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolDisambiguationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolDisambiguationTests.swift @@ -324,7 +324,7 @@ class SymbolDisambiguationTests: XCTestCase { let bundle = DocumentationBundle( info: DocumentationBundle.Info( displayName: "SymbolDisambiguationTests", - identifier: "com.test.SymbolDisambiguationTests"), + id: "com.test.SymbolDisambiguationTests"), symbolGraphURLs: [swiftSymbolGraphURL, objcSymbolGraphURL], markupURLs: [], miscResourceURLs: [] diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift index b0c5a1b2d..481007c7e 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift @@ -1791,7 +1791,7 @@ class SymbolGraphLoaderTests: XCTestCase { let bundle = DocumentationBundle( info: DocumentationBundle.Info( displayName: "Test", - identifier: "com.example.test" + id: "com.example.test" ), baseURL: URL(string: "https://example.com/example")!, symbolGraphURLs: symbolGraphURLs, diff --git a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift index 6c59ab678..73aecb1dc 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift @@ -42,7 +42,7 @@ class DefaultCodeBlockSyntaxTests: XCTestCase { testBundleWithoutLanguageDefault = DocumentationBundle( info: DocumentationBundle.Info( displayName: testBundleWithLanguageDefault.displayName, - identifier: testBundleWithLanguageDefault.identifier, + id: DocumentationBundle.Identifier(rawValue: testBundleWithLanguageDefault.identifier), defaultCodeListingLanguage: nil ), baseURL: testBundleWithLanguageDefault.baseURL, diff --git a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift index ef75b5e81..dc49aa638 100644 --- a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift +++ b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift @@ -142,7 +142,7 @@ extension XCTestCase { let bundle = DocumentationBundle( info: DocumentationBundle.Info( displayName: "Test", - identifier: "com.example.test" + id: "com.example.test" ), baseURL: URL(string: "https://example.com/example")!, symbolGraphURLs: [], From bfa673bb410801681f1a2199b5e3013758585352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 13:43:35 +0200 Subject: [PATCH 04/17] Use new Identifier type in `DocumentationBundle` --- .../Infrastructure/DocumentationBundle.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift index 3e434ec5e..f5b5beaea 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift @@ -49,13 +49,14 @@ public struct DocumentationBundle { info.displayName } - /** - The documentation bundle identifier. - - An identifier string that specifies the app type of the bundle. The string should be in reverse DNS format using only the Roman alphabet in upper and lower case (A–Z, a–z), the dot (“.”), and the hyphen (“-”). - */ + @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") public var identifier: String { - info.id.rawValue + id.rawValue + } + + /// The documentation bundle's stable and locally unique identifier. + public var id: DocumentationBundle.Identifier { + info.id } /** From 98c6a58c58916064982c59feecd43eac01574201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 13:57:59 +0200 Subject: [PATCH 05/17] Update code to not use deprecated `identifier` property --- .../Convert/ConvertService.swift | 2 +- .../ConvertActionConverter.swift | 4 +- .../Infrastructure/DocumentationContext.swift | 28 ++-- .../Link Resolution/LinkResolver.swift | 4 +- .../GeneratedDocumentationTopics.swift | 2 +- .../UnresolvedTopicReference+Symbol.swift | 2 +- .../LinkTargets/LinkDestinationSummary.swift | 2 +- .../Rendering/RenderNodeTranslator.swift | 2 +- .../Semantics/Media/ImageMedia.swift | 2 +- .../Semantics/Media/VideoMedia.swift | 4 +- .../Semantics/Metadata/CallToAction.swift | 2 +- .../Semantics/Metadata/PageImage.swift | 2 +- .../Semantics/ReferenceResolver.swift | 4 +- .../Semantics/Tutorial/Tasks/Steps/Code.swift | 4 +- .../Semantics/Tutorial/Tutorial.swift | 2 +- .../Actions/Convert/ConvertAction.swift | 6 +- .../Convert/ConvertFileWritingConsumer.swift | 2 +- .../Benchmark/TopicGraphHashTests.swift | 4 +- .../Indexing/NavigatorIndexTests.swift | 6 +- .../Infrastructure/AnchorSectionTests.swift | 18 +-- .../AutoCapitalizationTests.swift | 6 +- .../AutomaticCurationTests.swift | 40 +++--- .../DocumentationContextTests.swift | 114 ++++++++-------- .../DocumentationCuratorTests.swift | 8 +- .../ExternalReferenceResolverTests.swift | 36 ++--- .../Infrastructure/NodeTagsTests.swift | 4 +- .../Infrastructure/PathHierarchyTests.swift | 2 +- .../PresentationURLGeneratorTests.swift | 8 +- .../ReferenceResolverTests.swift | 22 +-- ...SymbolGraphRelationshipsBuilderTests.swift | 10 +- .../LinkDestinationSummaryTests.swift | 4 +- .../Model/LineHighlighterTests.swift | 2 +- .../ParametersAndReturnValidatorTests.swift | 14 +- ...opertyListPossibleValuesSectionTests.swift | 8 +- .../Model/RenderContentMetadataTests.swift | 14 +- .../RenderHierarchyTranslatorTests.swift | 2 +- .../Model/RenderNodeSerializationTests.swift | 8 +- .../SemaToRenderNodeMultiLanguageTests.swift | 2 +- .../Model/SemaToRenderNodeTests.swift | 126 +++++++++--------- .../AvailabilityRenderOrderTests.swift | 2 +- .../ConstraintsRenderSectionTests.swift | 16 +-- .../DeclarationsRenderSectionTests.swift | 10 +- .../Rendering/DefaultAvailabilityTests.swift | 2 +- .../Rendering/DeprecationSummaryTests.swift | 14 +- .../MentionsRenderSectionTests.swift | 6 +- .../Rendering/PageKindTests.swift | 2 +- .../Rendering/PlatformAvailabilityTests.swift | 16 +-- .../Rendering/RESTSymbolsTests.swift | 2 +- ...enderBlockContent_ThematicBreakTests.swift | 6 +- .../RenderContentCompilerTests.swift | 6 +- .../Rendering/RenderMetadataTests.swift | 4 +- ...derNodeTranslatorSymbolVariantsTests.swift | 4 +- .../Rendering/RenderNodeTranslatorTests.swift | 64 ++++----- .../Rendering/SampleDownloadTests.swift | 2 +- .../Rendering/TermListTests.swift | 6 +- .../ArticleSymbolMentionsTests.swift | 6 +- .../Semantics/DoxygenTests.swift | 2 +- .../Semantics/VideoMediaTests.swift | 2 +- .../Semantics/VolumeTests.swift | 2 +- .../XCTestCase+LoadingTestData.swift | 4 +- .../ConvertActionIndexerTests.swift | 4 +- .../ConvertActionTests.swift | 4 +- .../OutOfProcessReferenceResolverTests.swift | 22 +-- .../SemanticAnalyzerTests.swift | 2 +- .../Utility/TestFileSystemTests.swift | 2 +- 65 files changed, 372 insertions(+), 372 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift index 10fcba85f..afd6ea808 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift @@ -267,7 +267,7 @@ public struct ConvertService: DocumentationService { .compactMap { (value, isDocumentationExtensionContent) -> (ResolvedTopicReference, RenderReferenceStore.TopicContent)? in let (topicReference, article) = value - guard let bundle = context.bundle, bundle.identifier == topicReference.bundleIdentifier else { return nil } + guard let bundle = context.bundle, bundle.id.rawValue == topicReference.bundleIdentifier else { return nil } let renderer = DocumentationContentRenderer(documentationContext: context, bundle: bundle) let documentationNodeKind: DocumentationNode.Kind = isDocumentationExtensionContent ? .unknownSymbol : .article diff --git a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift index 7820427b5..0164a3095 100644 --- a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift +++ b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift @@ -161,7 +161,7 @@ package enum ConvertActionConverter { if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled { do { - let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.identifier) + let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation) if !emitDigest { @@ -191,7 +191,7 @@ package enum ConvertActionConverter { break } - try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleIdentifier: bundle.identifier)) + try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleIdentifier: bundle.id.rawValue)) // Log the finalized topic graph checksum. benchmark(add: Benchmark.TopicGraphHash(context: context)) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index dc1eced4b..52cd38e2c 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -328,7 +328,7 @@ public class DocumentationContext { self._configuration = configuration self.linkResolver = LinkResolver(dataProvider: dataProvider) - ResolvedTopicReference.enableReferenceCaching(for: bundle.identifier) + ResolvedTopicReference.enableReferenceCaching(for: bundle.id.rawValue) try register(bundle) } @@ -392,7 +392,7 @@ public class DocumentationContext { return legacyDataProvider.bundles[identifier] case .new: assert(bundle?.identifier == identifier, "New code shouldn't pass unknown bundle identifiers to 'DocumentationContext.bundle(identifier:)'.") - return bundle?.identifier == identifier ? bundle : nil + bundle?.id.rawValue == identifier ? bundle : nil } } @@ -914,7 +914,7 @@ public class DocumentationContext { let (url, analyzed) = analyzedDocument let path = NodeURLGenerator.pathForSemantic(analyzed, source: url, bundle: bundle) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) // Since documentation extensions' filenames have no impact on the URL of pages, there is no need to enforce unique filenames for them. // At this point we consider all articles with an H1 containing link a "documentation extension." @@ -1407,7 +1407,7 @@ public class DocumentationContext { } // Resolve any external references first - preResolveExternalLinks(references: Array(moduleReferences.values) + combinedSymbols.keys.compactMap({ documentationCache.reference(symbolID: $0) }), localBundleID: bundle.identifier) + preResolveExternalLinks(references: Array(moduleReferences.values) + combinedSymbols.keys.compactMap({ documentationCache.reference(symbolID: $0) }), localBundleID: bundle.id.rawValue) // Look up and add symbols that are _referenced_ in the symbol graph but don't exist in the symbol graph. try resolveExternalSymbols(in: combinedSymbols, relationships: combinedRelationshipsBySelector) @@ -1776,7 +1776,7 @@ public class DocumentationContext { private func registerMiscResources(from bundle: DocumentationBundle) throws { let miscResources = Set(bundle.miscResourceURLs) - try assetManagers[bundle.identifier, default: DataAssetManager()].register(data: miscResources) + try assetManagers[bundle.id.rawValue, default: DataAssetManager()].register(data: miscResources) } private func registeredAssets(withExtensions extensions: Set? = nil, inContexts contexts: [DataAsset.Context] = DataAsset.Context.allCases, forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { @@ -1932,7 +1932,7 @@ public class DocumentationContext { let title = articleResult.source.deletingPathExtension().lastPathComponent // Create a new root-looking reference let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: NodeURLGenerator.Path.documentation(path: title).stringValue, sourceLanguages: [DocumentationContext.defaultLanguage(in: nil /* article-only content has no source language information */)] ) @@ -1971,7 +1971,7 @@ public class DocumentationContext { let path = NodeURLGenerator.Path.documentation(path: title).stringValue let sourceLanguage = DocumentationContext.defaultLanguage(in: []) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguages: [sourceLanguage]) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguages: [sourceLanguage]) let graphNode = TopicGraph.Node(reference: reference, kind: .module, source: .external, title: title) topicGraph.addNode(graphNode) @@ -2036,7 +2036,7 @@ public class DocumentationContext { let defaultSourceLanguage = defaultLanguage(in: availableSourceLanguages) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguages: availableSourceLanguages // FIXME: Pages in article-only catalogs should not be inferred as "Swift" as a fallback @@ -2316,7 +2316,7 @@ public class DocumentationContext { tutorialTableOfContentsResults.map(referencedSemanticObject) + tutorials.map(referencedSemanticObject) + tutorialArticles.map(referencedSemanticObject), - localBundleID: bundle.identifier) + localBundleID: bundle.id.rawValue) resolveLinks( tutorialTableOfContents: tutorialTableOfContentsResults, @@ -2358,7 +2358,7 @@ public class DocumentationContext { // Article curation is only done automatically if there is only one root module if let rootNode = rootNodeForAutomaticCuration { let articleReferences = try autoCurateArticles(otherArticles, startingFrom: rootNode) - preResolveExternalLinks(references: articleReferences, localBundleID: bundle.identifier) + preResolveExternalLinks(references: articleReferences, localBundleID: bundle.id.rawValue) resolveLinks(curatedReferences: Set(articleReferences), bundle: bundle) } @@ -2373,7 +2373,7 @@ public class DocumentationContext { linkResolver.localResolver.addAnchorForSymbols(localCache: documentationCache) // Fifth, resolve links in nodes that are added solely via curation - preResolveExternalLinks(references: Array(allCuratedReferences), localBundleID: bundle.identifier) + preResolveExternalLinks(references: Array(allCuratedReferences), localBundleID: bundle.id.rawValue) resolveLinks(curatedReferences: allCuratedReferences, bundle: bundle) if configuration.convertServiceConfiguration.fallbackResolver != nil { @@ -2671,12 +2671,12 @@ public class DocumentationContext { */ private func unregister(_ bundle: DocumentationBundle) { let referencesToRemove = topicGraph.nodes.keys.filter { reference in - return reference.bundleIdentifier == bundle.identifier + return reference.bundleIdentifier == bundle.id.rawValue } for reference in referencesToRemove { - topicGraph.edges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.identifier }) - topicGraph.reverseEdges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.identifier }) + topicGraph.edges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.id.rawValue }) + topicGraph.reverseEdges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.id.rawValue }) topicGraph.nodes[reference] = nil } } diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index 4a7c25303..c56c037a3 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -93,7 +93,7 @@ public class LinkResolver { // Check if this is a link to an external documentation source that should have previously been resolved in `DocumentationContext.preResolveExternalLinks(...)` if let bundleID = unresolvedReference.bundleIdentifier, - !context._registeredBundles.contains(where: { $0.identifier == bundleID || urlReadablePath($0.displayName) == bundleID }) + !context._registeredBundles.contains(where: { $0.id.rawValue == bundleID || urlReadablePath($0.displayName) == bundleID }) { return .failure(unresolvedReference, TopicReferenceResolutionErrorInfo("No external resolver registered for \(bundleID.singleQuoted).")) } @@ -172,7 +172,7 @@ private final class FallbackResolverBasedLinkResolver { let referenceBundleIdentifier = unresolvedReference.bundleIdentifier ?? parent.bundleIdentifier guard let fallbackResolver = context.configuration.convertServiceConfiguration.fallbackResolver, // This uses an underscored internal variant of `registeredBundles` to avoid deprecation warnings and remain compatible with legacy data providers. - let knownBundleIdentifier = context._registeredBundles.first(where: { $0.identifier == referenceBundleIdentifier || urlReadablePath($0.displayName) == referenceBundleIdentifier })?.identifier, + let knownBundleIdentifier = context._registeredBundles.first(where: { $0.id.rawValue == referenceBundleIdentifier || urlReadablePath($0.displayName) == referenceBundleIdentifier })?.id.rawValue, fallbackResolver.bundleIdentifier == knownBundleIdentifier else { return nil diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift index 2186e0e39..14036f87a 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift @@ -107,7 +107,7 @@ enum GeneratedDocumentationTopics { // Create the collection topic reference let collectionReference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: NodeURLGenerator.Path.documentationCuration( parentPath: parent.path, articleName: title diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/UnresolvedTopicReference+Symbol.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/UnresolvedTopicReference+Symbol.swift index 17f4b3106..42cacab44 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/UnresolvedTopicReference+Symbol.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/UnresolvedTopicReference+Symbol.swift @@ -18,7 +18,7 @@ extension UnresolvedTopicReference { init?(symbolReference: SymbolReference, bundle: DocumentationBundle) { guard var components = URLComponents(string: symbolReference.path) else { return nil } components.scheme = ResolvedTopicReference.urlScheme - components.host = bundle.identifier + components.host = bundle.id.rawValue if !components.path.hasPrefix("/") { components.path.insert("/", at: components.path.startIndex) } diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index 9a9fa77f7..80df9f863 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -311,7 +311,7 @@ public extension DocumentationNode { renderNode: RenderNode, includeTaskGroups: Bool = true ) -> [LinkDestinationSummary] { - guard let bundle = context.bundle, bundle.identifier == reference.bundleIdentifier else { + guard let bundle = context.bundle, bundle.id.rawValue == reference.bundleIdentifier else { // Don't return anything for external references that don't have a bundle in the context. return [] } diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index f134c2bc7..f377ccb83 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -2005,7 +2005,7 @@ fileprivate typealias BundleModuleIdentifier = String extension BundleModuleIdentifier { fileprivate init(bundle: DocumentationBundle, moduleName: String) { - self = "\(bundle.identifier):\(moduleName)" + self = "\(bundle.id):\(moduleName)" } } diff --git a/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift b/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift index 059963724..a6e97df00 100644 --- a/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift +++ b/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift @@ -19,7 +19,7 @@ public final class ImageMedia: Semantic, Media, AutomaticDirectiveConvertible { @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public private(set) var source: ResourceReference diff --git a/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift b/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift index 1e3002603..66a40e44c 100644 --- a/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift +++ b/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift @@ -21,7 +21,7 @@ public final class VideoMedia: Semantic, Media, AutomaticDirectiveConvertible { @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public private(set) var source: ResourceReference @@ -44,7 +44,7 @@ public final class VideoMedia: Semantic, Media, AutomaticDirectiveConvertible { /// An image to be shown when the video isn't playing. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public private(set) var poster: ResourceReference? = nil diff --git a/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift b/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift index 9fbc23840..bc2fa520f 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift @@ -60,7 +60,7 @@ public final class CallToAction: Semantic, AutomaticDirectiveConvertible { /// The location of the associated link, as a reference to a file in this documentation bundle. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public var file: ResourceReference? = nil diff --git a/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift b/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift index 4b7999c5c..d3ef43c86 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift @@ -28,7 +28,7 @@ public final class PageImage: Semantic, AutomaticDirectiveConvertible { /// The base file name of an image in your documentation catalog. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public private(set) var source: ResourceReference diff --git a/Sources/SwiftDocC/Semantics/ReferenceResolver.swift b/Sources/SwiftDocC/Semantics/ReferenceResolver.swift index 56f86a10a..9da23a192 100644 --- a/Sources/SwiftDocC/Semantics/ReferenceResolver.swift +++ b/Sources/SwiftDocC/Semantics/ReferenceResolver.swift @@ -544,13 +544,13 @@ fileprivate extension URL { extension Image { func reference(in bundle: DocumentationBundle) -> ResourceReference? { guard let source else { - return ResourceReference(bundleIdentifier: bundle.identifier, path: "") + return ResourceReference(bundleIdentifier: bundle.id.rawValue, path: "") } if let url = URL(string: source), url.isLikelyWebURL { return nil } else { - return ResourceReference(bundleIdentifier: bundle.identifier, path: source) + return ResourceReference(bundleIdentifier: bundle.id.rawValue, path: source) } } } diff --git a/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift b/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift index 786d42260..b2a577b50 100644 --- a/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift +++ b/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift @@ -67,7 +67,7 @@ public final class Code: Semantic, DirectiveConvertible { Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .warning, allowedDirectives: [ImageMedia.directiveName, VideoMedia.directiveName]).analyze(directive, children: directive.children, source: source, for: bundle, in: context, problems: &problems) guard let requiredFileReference = Semantic.Analyses.HasArgument(severityIfNotFound: .warning).analyze(directive, arguments: arguments, problems: &problems) else { return nil } - let fileReference = ResourceReference(bundleIdentifier: bundle.identifier, path: requiredFileReference) + let fileReference = ResourceReference(bundleIdentifier: bundle.id.rawValue, path: requiredFileReference) guard let requiredFileName = Semantic.Analyses.HasArgument(severityIfNotFound: .warning).analyze(directive, arguments: arguments, problems: &problems) else { return nil } @@ -83,7 +83,7 @@ public final class Code: Semantic, DirectiveConvertible { let (optionalPreview, _) = Semantic.Analyses.HasExactlyOneImageOrVideoMedia(severityIfNotFound: nil).analyze(directive, children: directive.children, source: source, for: bundle, in: context, problems: &problems) let optionalPreviousFileReference = Semantic.Analyses.HasArgument(severityIfNotFound: nil).analyze(directive, arguments: arguments, problems: &problems).map { argument in - ResourceReference(bundleIdentifier: bundle.identifier, path: argument) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argument) } self.init(originalMarkup: directive, fileReference: fileReference, fileName: requiredFileName, previousFileReference: optionalPreviousFileReference, shouldResetDiff: shouldResetDiff, preview: optionalPreview) diff --git a/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift b/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift index 429bdbcca..72dad4fa1 100644 --- a/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift +++ b/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift @@ -23,7 +23,7 @@ public final class Tutorial: Semantic, AutomaticDirectiveConvertible, Abstracted /// Project files to download to get started with the ``Tutorial``. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.identifier, path: argumentValue) + ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) } ) public private(set) var projectFiles: ResourceReference? = nil diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift index 717b58a1c..7e8a3cb7d 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift @@ -276,7 +276,7 @@ public struct ConvertAction: AsyncAction { workingDirectory: temporaryFolder, fileManager: fileManager) - let indexer = try Indexer(outputURL: temporaryFolder, bundleIdentifier: bundle.identifier) + let indexer = try Indexer(outputURL: temporaryFolder, bundleIdentifier: bundle.id.rawValue) let context = try DocumentationContext(bundle: bundle, dataProvider: dataProvider, diagnosticEngine: diagnosticEngine, configuration: configuration) @@ -288,7 +288,7 @@ public struct ConvertAction: AsyncAction { indexer: indexer, enableCustomTemplates: experimentalEnableCustomTemplates, transformForStaticHostingIndexHTML: transformForStaticHosting ? indexHTML : nil, - bundleIdentifier: bundle.identifier + bundleIdentifier: bundle.id.rawValue ) if experimentalModifyCatalogWithGeneratedCuration, let catalogURL = rootURL { @@ -422,7 +422,7 @@ public struct ConvertAction: AsyncAction { context: context, indexer: nil, transformForStaticHostingIndexHTML: nil, - bundleIdentifier: bundle.identifier + bundleIdentifier: bundle.id.rawValue ) try outputConsumer.consume(benchmarks: Benchmark.main) diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift index c8ecd1eb0..08f857e00 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift @@ -79,7 +79,7 @@ struct ConvertFileWritingConsumer: ConvertOutputConsumer { } // TODO: Supporting a single bundle for the moment. - let bundleIdentifier = bundle.identifier + let bundleIdentifier = bundle.id.rawValue assert(bundleIdentifier == self.assetPrefixComponent, "Unexpectedly encoding assets for a bundle other than the one this output consumer was created for.") // Create images directory if needed. diff --git a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift index a3aa445d1..02dc299f1 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift @@ -105,7 +105,7 @@ class TopicGraphHashTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -117,7 +117,7 @@ class TopicGraphHashTests: XCTestCase { ]) // Verify correct hierarchy under `MyKit` in the topic graph dump including external symbols. - let myKitRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let myKitRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let myKitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(myKitRef)) let expectedHierarchyWithExternalSymbols = """ diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 01193117a..31cdc61ac 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -635,8 +635,8 @@ Root let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) - let fromMemoryBuilder = NavigatorIndex.Builder(outputURL: try createTemporaryDirectory(), bundleIdentifier: bundle.identifier, sortRootChildrenByName: true, groupByLanguage: true) - let fromDecodedBuilder = NavigatorIndex.Builder(outputURL: try createTemporaryDirectory(), bundleIdentifier: bundle.identifier, sortRootChildrenByName: true, groupByLanguage: true) + let fromMemoryBuilder = NavigatorIndex.Builder(outputURL: try createTemporaryDirectory(), bundleIdentifier: bundle.id.rawValue, sortRootChildrenByName: true, groupByLanguage: true) + let fromDecodedBuilder = NavigatorIndex.Builder(outputURL: try createTemporaryDirectory(), bundleIdentifier: bundle.id.rawValue, sortRootChildrenByName: true, groupByLanguage: true) fromMemoryBuilder.setup() fromDecodedBuilder.setup() @@ -1158,7 +1158,7 @@ Root let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) let targetURL = try createTemporaryDirectory() - let builder = NavigatorIndex.Builder(outputURL: targetURL, bundleIdentifier: bundle.identifier, sortRootChildrenByName: true) + let builder = NavigatorIndex.Builder(outputURL: targetURL, bundleIdentifier: bundle.id.rawValue, sortRootChildrenByName: true) builder.setup() for identifier in context.knownPages { diff --git a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift index 20241abbf..507b77c6b 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift @@ -21,15 +21,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -79,15 +79,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -137,15 +137,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the article page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion diff --git a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift index 8681a3722..2c689b381 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift @@ -66,7 +66,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -113,7 +113,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -156,7 +156,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift index 5adc4864e..da312e7da 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift @@ -98,7 +98,7 @@ class AutomaticCurationTests: XCTestCase { file: StaticString = #file, line: UInt = #line ) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = try XCTUnwrap(translator.visit(node.semantic) as? RenderNode, file: file, line: line) @@ -130,7 +130,7 @@ class AutomaticCurationTests: XCTestCase { try sideKit.write(to: url.appendingPathComponent("documentation").appendingPathComponent("sidekit.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile the render node to flex the automatic curator let symbol = node.semantic as! Symbol @@ -180,7 +180,7 @@ class AutomaticCurationTests: XCTestCase { """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -342,7 +342,7 @@ class AutomaticCurationTests: XCTestCase { // The first topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -358,7 +358,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -371,7 +371,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -383,21 +383,21 @@ class AutomaticCurationTests: XCTestCase { // The automatically curated symbols shouldn't have a See Also section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -424,7 +424,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the framework render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -437,7 +437,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the `A` render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed/A", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/A", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -477,7 +477,7 @@ class AutomaticCurationTests: XCTestCase { // Load the "MixedLanguageProtocol Implementations" API COllection let protocolImplementationsNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedLanguageFramework/MixedLanguageClassConformingToProtocol/MixedLanguageProtocol-Implementations", sourceLanguages: [.swift, .objectiveC] ) @@ -503,7 +503,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedLanguageFramework", sourceLanguages: [.swift, .objectiveC] ) @@ -577,7 +577,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/Whatsit", sourceLanguages: [.objectiveC] ) @@ -603,7 +603,7 @@ class AutomaticCurationTests: XCTestCase { let classDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/Whatsit/Whatsit", sourceLanguages: [.objectiveC] ) @@ -638,7 +638,7 @@ class AutomaticCurationTests: XCTestCase { let containerDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/ThirdOrder/SomeStruct", sourceLanguages: [.swift] ) @@ -665,7 +665,7 @@ class AutomaticCurationTests: XCTestCase { let rootDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CxxSymbols", sourceLanguage: .objectiveC ) @@ -755,7 +755,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -809,7 +809,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -866,7 +866,7 @@ class AutomaticCurationTests: XCTestCase { let catalogURL = try exampleDocumentation.write(inside: createTemporaryDirectory()) let (_, bundle, context) = try loadBundle(from: catalogURL) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index b287205e0..65ec10847 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -48,7 +48,7 @@ class DocumentationContextTests: XCTestCase { // Test resolving let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc:/TestTutorial")!) - let parent = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "", sourceLanguage: .swift) guard case let .success(resolved) = context.resolve(.unresolved(unresolved), in: parent) else { XCTFail("Couldn't resolve \(unresolved)") @@ -85,7 +85,7 @@ class DocumentationContextTests: XCTestCase { func testLoadEntity() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let identifier = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "some.other.bundle", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift))) @@ -436,11 +436,11 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let existingImageReference = ResourceReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "introposter" ) let nonexistentImageReference = ResourceReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "nonexistent-image" ) XCTAssertTrue( @@ -453,11 +453,11 @@ class DocumentationContextTests: XCTestCase { ) let correctImageReference = ResourceReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "figure1.jpg" ) let incorrectImageReference = ResourceReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "images/figure1.jpg" ) XCTAssertTrue( @@ -1235,7 +1235,7 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try loadBundle(catalog: testCatalog) let renderContext = RenderContext(documentationContext: context, bundle: bundle) - let identifier = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift) let node = try context.entity(with: identifier) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -1334,7 +1334,7 @@ let expected = """ } func createNode(in context: DocumentationContext, bundle: DocumentationBundle, parent: ResolvedTopicReference, name: String) throws -> (DocumentationNode, TopicGraph.Node) { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) let node = DocumentationNode(reference: reference, kind: .article, sourceLanguage: .swift, name: .conceptual(title: name), markup: Document(parsing: "# \(name)"), semantic: nil) let tgNode = TopicGraph.Node(reference: reference, kind: .article, source: .external, title: name) @@ -1349,7 +1349,7 @@ let expected = """ func testSortingBreadcrumbsOfEqualDistanceToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) /// /// Create nodes in alphabetical order @@ -1383,7 +1383,7 @@ let expected = """ func testSortingBreadcrumbsOfDifferentDistancesToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let tgMykitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(mykit)) /// @@ -1431,7 +1431,7 @@ let expected = """ }) // Verify the node is a child of the module node when the graph is loaded. - let sideClassReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let sideClassReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) let parents = context.parents(of: sideClassReference) XCTAssertEqual(parents.map {$0.path}, ["/documentation/SideKit"]) } @@ -1840,7 +1840,7 @@ let expected = """ let problems = context.problems XCTAssertEqual(problems.count, 0, "Unexpected problems: \(problems.map(\.diagnostic.summary).sorted())") - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let entity = try context.entity(with: moduleReference) let moduleSymbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -2097,7 +2097,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) let node = try context.entity(with: reference) XCTAssertEqual((node.semantic as? Symbol)?.abstract?.plainText, "Extend a symbol with a space in its name.") @@ -2147,7 +2147,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -2156,7 +2156,7 @@ let expected = """ } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -2600,7 +2600,7 @@ let expected = """ func testNavigatorTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func renderNodeForPath(path: String) throws -> (DocumentationNode, RenderNode) { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2791,7 +2791,7 @@ let expected = """ let (bundle, context) = try testBundleAndContext(named: "TestBundle") // Verify task group ranges are persisted for symbol docs - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let symbol = try XCTUnwrap((try? context.entity(with: symbolReference))?.semantic as? Symbol) let symbolTopics = try XCTUnwrap(symbol.topics) symbolTopics.originalLinkRangesByGroup.forEach { group in @@ -2799,7 +2799,7 @@ let expected = """ } // Verify task group ranges are persisted for articles - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let article = try XCTUnwrap((try? context.entity(with: articleReference))?.semantic as? Article) let articleTopics = try XCTUnwrap(article.topics) articleTopics.originalLinkRangesByGroup.forEach { group in @@ -3471,10 +3471,10 @@ let expected = """ """.write(to: url.appendingPathComponent("fifthTestMember.md"), atomically: true, encoding: .utf8) } - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) // Fetch the "OverloadedParentStruct" node - let reference1 = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) let node1 = try context.entity(with: reference1) let symbol1 = try XCTUnwrap(node1.semantic as? Symbol) @@ -3487,7 +3487,7 @@ let expected = """ XCTAssertTrue(tgNode1.contains(articleReference)) // Fetch the "fifthTestMember" node - let reference2 = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) + let reference2 = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) let node2 = try context.entity(with: reference2) let symbol2 = try XCTUnwrap(node2.semantic as? Symbol) @@ -3570,7 +3570,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3579,7 +3579,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3588,7 +3588,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3597,7 +3597,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3606,7 +3606,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3681,7 +3681,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3690,7 +3690,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3699,7 +3699,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3708,7 +3708,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3742,7 +3742,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3751,7 +3751,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3777,7 +3777,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Something", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Something", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3885,7 +3885,7 @@ let expected = """ let identifiers = context.problems.map(\.diagnostic.identifier) XCTAssertFalse(identifiers.contains(where: { $0 == "org.swift.docc.ArticleUncurated" })) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNil(article.topics) @@ -3922,7 +3922,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNotNil(article.topics) @@ -3965,7 +3965,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) @@ -3993,7 +3993,7 @@ let expected = """ .replacingOccurrences(of: " - ", with: " - ") .write(to: myKitURL, atomically: true, encoding: .utf8) } - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) // Try resolving the new resolvable node switch context.resolve(.unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc:resolvable-article")!)), in: moduleReference) { @@ -4147,12 +4147,12 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Resolve from various locations in the bundle for parent in [bundle.rootReference, bundle.documentationRootReference, bundle.tutorialTableOfContentsContainer] { @@ -4184,14 +4184,14 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) let symbolReference = try XCTUnwrap(context.documentationCache.reference(symbolID: "s:12Minimal_docs4TestV")) @@ -4244,9 +4244,9 @@ let expected = """ // Load the bundle let (_, bundle, context) = try loadBundle(from: tempFolderURL) - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs", sourceLanguage: .swift) - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Verify we resolve/not resolve non-symbols when calling directly context.resolve(...) // with an explicit preference. @@ -4272,7 +4272,7 @@ let expected = """ // Verify the context contains the conflicting topic names // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol XCTAssertNotNil(context.documentationCache[symbolReference]) @@ -4315,8 +4315,8 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the module and symbol node kinds. - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) XCTAssertEqual(context.topicGraph.nodeWithReference(symbolReference)?.kind, .structure) XCTAssertEqual(context.topicGraph.nodeWithReference(moduleReference)?.kind, .module) @@ -4686,7 +4686,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) XCTAssertEqual( context.topicGraph.reverseEdgesGraph.cycles(from: reference).map { $0.map(\.lastPathComponent) }, @@ -4771,7 +4771,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { var seenIndices = Set() @@ -4859,7 +4859,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { switch context.resolve(.unresolved(.init(topicURL: .init(symbolPath: "SymbolName-\(kindID.identifier)"))), in: moduleReference, fromSymbolLink: true) { @@ -4991,7 +4991,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5068,7 +5068,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5143,7 +5143,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5213,7 +5213,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift index f17f0ad7d..9f48acd1d 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift @@ -482,7 +482,7 @@ class DocumentationCuratorTests: XCTestCase { func testMixedManualAndAutomaticCuration() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) let entity = try context.entity(with: reference) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -497,14 +497,14 @@ class DocumentationCuratorTests: XCTestCase { // Verify that the ONLY curation for `TopClass/name` is the manual curation under `MyArticle` // and the automatic curation under `TopClass` is not present. - let nameReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) + let nameReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: nameReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], ]) // Verify that the BOTH manual curations for `TopClass/age` are preserved // even if one of the manual curations overlaps with the inheritance edge from the symbol graph. - let ageReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) + let ageReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: ageReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass"], ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], @@ -516,7 +516,7 @@ class DocumentationCuratorTests: XCTestCase { func testMultipleManualCurationIsPreserved() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: reference).map({ $0.map({ $0.path }) }), [ [ diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 95eb507a9..1c1223938 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -69,7 +69,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://com.external.testbundle/article")!) - let parent = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyClass", sourceLanguage: .swift) guard case let .success(resolved) = context.resolve(.unresolved(unresolved), in: parent) else { XCTFail("Couldn't resolve \(unresolved)") @@ -120,7 +120,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) let sideClassReference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift ) @@ -165,7 +165,7 @@ class ExternalReferenceResolverTests: XCTestCase { let bundleIdentifier = bundle.identifier let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://\(bundleIdentifier)/ArticleThatDoesNotExistInLocally")!) - let parent = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "", sourceLanguage: .swift) do { context.configuration.externalDocumentationConfiguration.sources = [:] @@ -254,7 +254,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let fileURL = context.documentURL(for: node.reference) else { XCTFail("Unable to find the file for \(node.reference.path)") @@ -308,7 +308,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -353,7 +353,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (bundle, context) = try loadBundle(catalog: tempFolder, configuration: configuration) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/article", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -400,7 +400,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -499,7 +499,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SomeSample", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SomeSample", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -612,7 +612,7 @@ class ExternalReferenceResolverTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -768,7 +768,7 @@ class ExternalReferenceResolverTests: XCTestCase { "The external reference resolver error message is included in that problem's error summary.") // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let renderNode = try converter.convert(entity) @@ -810,7 +810,7 @@ class ExternalReferenceResolverTests: XCTestCase { .write(to: myClassMDURL, atomically: true, encoding: .utf8) }) - let myClassRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let myClassRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let documentationNode = try context.entity(with: myClassRef) // Verify the external link was resolved in markup. @@ -891,7 +891,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) let mixedLanguageFrameworkReference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedLanguageFramework", sourceLanguage: .swift ) @@ -967,7 +967,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -976,7 +976,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -1037,7 +1037,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/unit-test/First", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/First", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1051,7 +1051,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/unit-test/Second", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Second", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1175,7 +1175,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. @@ -1214,7 +1214,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))", file: file, line: line) // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. diff --git a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift index 62b4d685d..007db4a89 100644 --- a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift @@ -27,7 +27,7 @@ class NodeTagsTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL) // Verify that `Test` is marked as SPI. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) let node = try XCTUnwrap(context.entity(with: reference)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssertTrue(symbol.isSPI) @@ -39,7 +39,7 @@ class NodeTagsTests: XCTestCase { XCTAssertEqual(renderNode.metadata.tags, [.spi]) // Verify that the link to the node contains the SPI tag. - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) let moduleNode = try XCTUnwrap(context.entity(with: moduleReference)) let moduleSymbol = try XCTUnwrap(moduleNode.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index 7fb04508e..5f8c25901 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -1112,7 +1112,7 @@ class PathHierarchyTests: XCTestCase { let tree = try XCTUnwrap(linkResolver.pathHierarchy) // Test finding the parent via the `fromTopicReference` integration shim. - let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)]! + let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)]! XCTAssertNotNil(parentID) XCTAssertEqual(try tree.findSymbol(path: "globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") XCTAssertEqual(try tree.findSymbol(path: "MyKit/globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") diff --git a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift index 19981fb8b..72a0dd7a4 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift @@ -18,19 +18,19 @@ class PresentationURLGeneratorTests: XCTestCase { let generator = PresentationURLGenerator(context: context, baseURL: URL(string: "https://host:1024/webPrefix")!) // Test resolved tutorial reference - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(reference).absoluteString, "https://host:1024/webPrefix/tutorials/test-bundle/testtutorial") // Test resolved symbol reference - let symbol = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let symbol = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(symbol).absoluteString, "https://host:1024/webPrefix/documentation/mykit/myclass") // Test root - let root = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/", sourceLanguage: .swift) + let root = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(root).absoluteString, "https://host:1024/webPrefix/documentation") // Fragment - let fragment = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) + let fragment = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(fragment).absoluteString, "https://host:1024/webPrefix/path#test-URL-FRAGMENT") } } diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index 7f5a5ee8f..3f0bac41d 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -409,7 +409,7 @@ class ReferenceResolverTests: XCTestCase { func testCuratedExtensionRemovesEmptyPage() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithSingleExtension") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -421,7 +421,7 @@ class ReferenceResolverTests: XCTestCase { // Make sure that the symbol added in the extension is still present in the topic graph, // even though its synthetic "extended symbol" parents are not - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) } func testCuratedExtensionWithDanglingReference() throws { @@ -445,15 +445,15 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) // Load the RenderNode for the root article and make sure that the `Swift/Array` symbol link // is not rendered as a link - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -485,10 +485,10 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) } @@ -514,17 +514,17 @@ class ReferenceResolverTests: XCTestCase { XCTAssertFalse(context.problems.contains(where: { $0.diagnostic.identifier == "org.swift.docc.removedExtensionLinkDestination" || $0.diagnostic.identifier == "org.swift.docc.unresolvedTopicReference" })) // Because the `Swift/Array` extension has an extension article, the pages should not be marked as virtual - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedStructure })) } func testCuratedExtensionWithAdditionalConformance() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithConformanceAndExtension") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -540,7 +540,7 @@ class ReferenceResolverTests: XCTestCase { func testExtensionWithEmptyDeclarationFragments() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithEmptyDeclarationFragments") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index 6bd642a13..2d24ec724 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -24,10 +24,10 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let targetRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/B", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let targetRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/B", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: sourceType, mixins: [:]) let targetSymbol = SymbolGraph.Symbol(identifier: targetIdentifier, names: SymbolGraph.Symbol.Names(title: "B", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "B"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: targetType, mixins: [:]) @@ -130,8 +130,8 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: SymbolGraph.Symbol.Kind(parsedIdentifier: .class, displayName: "Class"), mixins: [:]) diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 64527bd04..05d3db508 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -98,7 +98,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) @@ -727,7 +727,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) diff --git a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift index f8444527c..bfa303902 100644 --- a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift +++ b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift @@ -51,7 +51,7 @@ class LineHighlighterTests: XCTestCase { let catalog = Self.makeCatalog(tutorial: tutorialFile, codeFiles: codeFiles) let (bundle, context) = try loadBundle(catalog: catalog) - let tutorialReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) let tutorial = try context.entity(with: tutorialReference).semantic as! Tutorial let section = tutorial.sections.first! return LineHighlighter(context: context, tutorialSection: section, tutorialReference: tutorialReference).highlights diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index 26d8cf017..bc7e93861 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -26,7 +26,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: `YES` if doing something was successful, or `NO` if an error occurred. // - (void)doSomethingWith:(NSInteger)someValue error:(NSError **)error; do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -47,7 +47,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: Some string. If an error occurs, this method returns `nil` and assigns an appropriate error object to the `error` parameter. // - (nullable NSString *)returnSomethingAndReturnError:(NSError **)error; do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -68,7 +68,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func doSomething(with someValue: Int) throws { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -93,7 +93,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func returnSomething() throws -> String { "" } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -435,7 +435,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -492,7 +492,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -534,7 +534,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift index acbf750ac..9b8f61f48 100644 --- a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift +++ b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift @@ -83,7 +83,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testAbsenceOfPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) // Check that the `Possible Values` section is not rendered if the symbol don't define any possible value. @@ -92,7 +92,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testUndocumentedPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let possibleValuesSection = try XCTUnwrap(try converter.convert(node).primaryContentSections.first(where: { $0.kind == .possibleValues}) as? PossibleValuesRenderSection) let possibleValues: [PossibleValuesRenderSection.NamedValue] = possibleValuesSection.values @@ -116,7 +116,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) @@ -136,7 +136,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) diff --git a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift index 6a46ba7b8..7e7f15ca6 100644 --- a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift @@ -68,7 +68,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTables() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -109,7 +109,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableSpans() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | @@ -162,7 +162,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableColumnAlignments() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | four | @@ -204,7 +204,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that a table with `nil` alignments and a table with all-unset alignments still compare as equal. func testRenderedTableEquality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -230,7 +230,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that two tables with otherwise-identical contents but different column alignments compare as unequal. func testRenderedTableInequality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let decodedTableWithUnsetColumns: RenderBlockContent.Table do { @@ -277,7 +277,7 @@ class RenderContentMetadataTests: XCTestCase { func testStrikethrough() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ~~Striken~~ text. @@ -300,7 +300,7 @@ class RenderContentMetadataTests: XCTestCase { func testHeadingAnchorShouldBeEncoded() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ## テスト diff --git a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift index cf065a548..3ae753a76 100644 --- a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift @@ -14,7 +14,7 @@ import XCTest class RenderHierarchyTranslatorTests: XCTestCase { func test() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let technologyReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let technologyReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift) var translator = RenderHierarchyTranslator(context: context, bundle: bundle) let renderHierarchy = translator.visitTutorialTableOfContentsNode(technologyReference)?.hierarchy diff --git a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift index a0d4454e1..c8c824973 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift @@ -93,7 +93,7 @@ class RenderNodeSerializationTests: XCTestCase { func testBundleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -116,7 +116,7 @@ class RenderNodeSerializationTests: XCTestCase { func testTutorialArticleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") @@ -141,7 +141,7 @@ class RenderNodeSerializationTests: XCTestCase { typealias JSONDictionary = [String: Any] let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -193,7 +193,7 @@ class RenderNodeSerializationTests: XCTestCase { func testDiffAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift index 452ee5b2d..0f94b384a 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift @@ -444,7 +444,7 @@ class SemaToRenderNodeMixedLanguageTests: XCTestCase { """.write(to: url.appendingPathComponent("bar.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssert(context.problems.isEmpty, "Encountered unexpected problems: \(context.problems)") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift index 032a0ef74..5f23c39a3 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift @@ -17,7 +17,7 @@ import SwiftDocCTestUtilities class SemaToRenderNodeTests: XCTestCase { func testCompileTutorial() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -404,7 +404,7 @@ class SemaToRenderNodeTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func assertTutorialWithPath(_ tutorialPath: String, hasBackground backgroundIdentifier: String) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: tutorialPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: tutorialPath, sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -432,7 +432,7 @@ class SemaToRenderNodeTests: XCTestCase { func testCompileTutorialArticle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) let article = node.semantic as! TutorialArticle @@ -570,7 +570,7 @@ class SemaToRenderNodeTests: XCTestCase { } private func assertCompileOverviewWithNoVolumes(bundle: DocumentationBundle, context: DocumentationContext, expectedProblemsCount: Int = 0) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -807,7 +807,7 @@ class SemaToRenderNodeTests: XCTestCase { try text.write(to: overviewURL, atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -941,7 +941,7 @@ class SemaToRenderNodeTests: XCTestCase { try JSONEncoder().encode(graph).write(to: graphURL) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Verify that `MyProtocol` the symbol is loaded in the topic graph, but the `MyProtocol` sidecar article was removed. let matches = context.knownPages.filter({ reference -> Bool in @@ -1326,7 +1326,7 @@ class SemaToRenderNodeTests: XCTestCase { // Check for constraints in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1346,7 +1346,7 @@ class SemaToRenderNodeTests: XCTestCase { }.joined(), "Label is Text, Observer inherits NSObject, and S conforms to StringProtocol.") // Check for constraints in render references - let parent = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let parent = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let parentSymbol = parent.semantic as! Symbol var parentTranslator = RenderNodeTranslator(context: context, bundle: bundle, identifier: parent.reference) @@ -1379,7 +1379,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnConformingType() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1401,7 +1401,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnProtocol() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1423,7 +1423,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderReferenceResolving() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1488,7 +1488,7 @@ class SemaToRenderNodeTests: XCTestCase { func testAvailabilityMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1549,7 +1549,7 @@ class SemaToRenderNodeTests: XCTestCase { } }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1576,7 +1576,7 @@ class SemaToRenderNodeTests: XCTestCase { func testMediaReferencesWithSpaces() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -1637,7 +1637,7 @@ Document @1:1-11:19 markup.debugDescription(options: .printSourceLocations)) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1679,7 +1679,7 @@ Document markup.debugDescription()) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1711,7 +1711,7 @@ Document func testCompileSymbolMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1819,7 +1819,7 @@ Document try content.write(to: targetURL.appendingPathComponent("article2.md"), atomically: true, encoding: .utf8) let (_, bundle, context) = try loadBundle(from: targetURL) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return translator.visit(article) as! RenderNode @@ -1907,7 +1907,7 @@ Document let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) return (bundle, context, reference) } @@ -2061,14 +2061,14 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: nil, deprecatedVersion: .init(major: 13, minor: 0, patch: 0), obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2084,7 +2084,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2092,7 +2092,7 @@ Document ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2108,7 +2108,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: true, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2116,7 +2116,7 @@ Document ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2131,7 +2131,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2151,7 +2151,7 @@ Document func testRenderMetadataExtendedModule() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2165,7 +2165,7 @@ Document // Verify that the render reference to a required symbol includes the 'required' key and the number of default implementations provided. do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2178,7 +2178,7 @@ Document // Verify that a required symbol includes a required metadata and default implementations do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2198,7 +2198,7 @@ Document // Verify that a required symbol does not include default implementations in Topics groups do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2213,7 +2213,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2242,7 +2242,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2261,7 +2261,7 @@ Document func testDocumentationRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2281,7 +2281,7 @@ Document func testTutorialsRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) let symbol = node.semantic as! TutorialTableOfContents var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2301,7 +2301,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol // Subheading with trailing "\n" @@ -2323,7 +2323,7 @@ Document func testRenderManualSeeAlsoInArticles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2346,7 +2346,7 @@ Document func testSafeSectionAnchorNames() throws { // Check that heading's anchor was safe-ified let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2367,7 +2367,7 @@ Document func testDuplicateNavigatorTitleIsRemoved() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2383,7 +2383,7 @@ Document func testNonDuplicateNavigatorTitleIsRendered() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2440,7 +2440,7 @@ Document """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -2461,7 +2461,7 @@ Document _ = translator.visit(tutorialTableOfContents) do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2532,7 +2532,7 @@ Document """.write(to: url.appendingPathComponent("TestTutorial.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2576,8 +2576,8 @@ Document XCTAssertEqual(Array(asides.content.dropFirst()), self.asidesStressTest) } - let dashReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) - let quoteReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) + let dashReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) + let quoteReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) try testReference(dashReference) try testReference(quoteReference) @@ -2587,7 +2587,7 @@ Document func testOriginMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let origin = try XCTUnwrap(symbol.origin) @@ -2609,7 +2609,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2636,7 +2636,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2662,7 +2662,7 @@ Document return p.diagnostic.summary == "Resource 'my-inherited-image.png' couldn't be found" })) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2691,7 +2691,7 @@ Document """.write(to: url.appendingPathComponent("inherited.md"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2836,7 +2836,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json")) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2866,7 +2866,7 @@ Document problem.diagnostic.summary.contains("my-inherited-image.png") })) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2901,7 +2901,7 @@ Document func testNonDocumentedSymbolNilAbstract() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3016,7 +3016,7 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -3057,9 +3057,9 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit", sourceLanguage: .swift) - let protocolReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) - let functionReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let protocolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let functionReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) // Verify the MyKit module @@ -3141,13 +3141,13 @@ Document // Verify that the inherited symbol got a path that accounts for the collision between // the struct `B` and the property `b`. - let inheritedSymbolReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) + let inheritedSymbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) XCTAssertNoThrow(try context.entity(with: inheritedSymbolReference)) // Verify that the inherited symbol is automatically curated with its correct // reference path under the inherited symbols API collection - let equatableImplementationsReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) + let equatableImplementationsReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) let equatableImplementationsNode = try context.entity(with: equatableImplementationsReference) let equatableImplementationsArticle = try XCTUnwrap(equatableImplementationsNode.semantic as? Article) let group = try XCTUnwrap(equatableImplementationsArticle.automaticTaskGroups.first) @@ -3179,7 +3179,7 @@ Document } """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") return @@ -3224,7 +3224,7 @@ Document ) let moduleReference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3267,7 +3267,7 @@ Document ) let articleReference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3436,7 +3436,7 @@ Document } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) let node = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -3487,7 +3487,7 @@ Document let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift index a98a474a0..a00e208eb 100644 --- a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift @@ -24,7 +24,7 @@ class AvailabilityRenderOrderTests: XCTestCase { try? FileManager.default.removeItem(at: bundleURL) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift index 2cef89d2b..637baa216 100644 --- a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift @@ -40,7 +40,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -70,7 +70,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -99,7 +99,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -129,7 +129,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -159,7 +159,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -190,7 +190,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -220,7 +220,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -258,7 +258,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift index 8dfb245c7..145cd912c 100644 --- a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift @@ -135,7 +135,7 @@ class DeclarationsRenderSectionTests: XCTestCase { func testAlternateDeclarations() throws { let (bundle, context) = try testBundleAndContext(named: "AlternateDeclarations") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AlternateDeclarations/MyClass/present(completion:)", sourceLanguage: .swift ) @@ -186,7 +186,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload1(param: Set) {} // func overload1(param: [Int: Int]) {} let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyOverloads/overload1(param:)", sourceLanguage: .swift ) @@ -237,7 +237,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload2(p1: (Int) -> Int?, p2: Int) {} // func overload2(p1: ((Int) -> Int)?, p2: Int) {} // <- overload group let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyOverloads/overload2(p1:p2:)", sourceLanguage: .swift ) @@ -292,7 +292,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload3(_ p: [T: T]) {} // func overload3(_ p: [K: V]) {} let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyOverloads/overload3(_:)", sourceLanguage: .swift ) @@ -342,7 +342,7 @@ class DeclarationsRenderSectionTests: XCTestCase { for hash in ["7eht8", "8p1lo", "858ja"] { let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyOverloads/overload3(_:)-\(hash)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift index d19a6acb1..913080351 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift @@ -336,7 +336,7 @@ class DefaultAvailabilityTests: XCTestCase { let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift index 469adb159..ea0449ba1 100644 --- a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift @@ -32,7 +32,7 @@ class DeprecationSummaryTests: XCTestCase { /// and it's preferred over the original deprecation note in the code docs. func testAuthoredDeprecatedSummary() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -63,7 +63,7 @@ class DeprecationSummaryTests: XCTestCase { }) // Verify the deprecation is still rendered. - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -83,7 +83,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass", sourceLanguage: .swift ) @@ -115,7 +115,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) @@ -137,7 +137,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass/init()", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass/coolFunc()", sourceLanguage: .swift ) @@ -195,7 +195,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass/init(config:cache:)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift index e8b5523cc..ff1f4a680 100644 --- a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift @@ -19,12 +19,12 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift ) let mentioningArticle = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift ) @@ -42,7 +42,7 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/MyClass/myFunction()", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift index 5ee093382..0cbe9c790 100644 --- a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift @@ -18,7 +18,7 @@ class PageKindTests: XCTestCase { private func generateRenderNodeFromBundle(bundleName: String, resolvedTopicPath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: bundleName) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: resolvedTopicPath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift index c5d52129d..fbc8f0080 100644 --- a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift @@ -36,7 +36,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -55,7 +55,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromExtension() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -73,7 +73,7 @@ class PlatformAvailabilityTests: XCTestCase { func testMultiplePlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -101,7 +101,7 @@ class PlatformAvailabilityTests: XCTestCase { func testArbitraryPlatformAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AvailabilityBundle/ArbitraryPlatforms", sourceLanguage: .swift ) @@ -127,7 +127,7 @@ class PlatformAvailabilityTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "AvailabilityOverrideBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -189,7 +189,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -221,7 +221,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift index b269c5d97..38201a0e7 100644 --- a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift @@ -332,7 +332,7 @@ class RESTSymbolsTests: XCTestCase { ] + extraFiles ) let (_, bundle, context) = try loadBundle(from: (try createTempFolder(content: [exampleDocumentation]))) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) let moduleSymbol = try XCTUnwrap((try context.entity(with: moduleReference)).semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: moduleReference) let renderNode = translator.visit(moduleSymbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift index 0cb5d9a81..e5740686f 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift @@ -40,7 +40,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -67,7 +67,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -97,7 +97,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift index 5014c6561..74f09d48a 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift @@ -16,7 +16,7 @@ import XCTest class RenderContentCompilerTests: XCTestCase { func testLinkOverrideTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ [Example](http://example.com) @@ -134,7 +134,7 @@ class RenderContentCompilerTests: XCTestCase { func testLineBreak() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" Backslash before new line\ @@ -199,7 +199,7 @@ class RenderContentCompilerTests: XCTestCase { func testThematicBreak() throws { let (bundle, context) = try testBundleAndContext() - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" diff --git a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift index 61b7d467e..c16d5a031 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift @@ -100,7 +100,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -127,7 +127,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift index cd7d283a1..773705462 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift @@ -1188,7 +1188,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: bundleName) let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -1225,7 +1225,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift index 5083baf50..e324d2805 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift @@ -19,7 +19,7 @@ class RenderNodeTranslatorTests: XCTestCase { private func findDiscussion(forSymbolPath: String, configureBundle: ((URL) throws -> Void)? = nil) throws -> ContentRenderSection? { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", configureBundle: configureBundle) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: forSymbolPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: forSymbolPath, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -291,7 +291,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let node = try context.entity(with: reference) let article = try XCTUnwrap(node.semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -375,7 +375,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -406,7 +406,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -440,7 +440,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -451,7 +451,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -462,7 +462,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -502,7 +502,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -525,7 +525,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -553,7 +553,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -564,7 +564,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -575,7 +575,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -605,7 +605,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify "Default Implementations" group on the implementing type do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -624,7 +624,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify automatically generated api collection do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -653,7 +653,7 @@ class RenderNodeTranslatorTests: XCTestCase { try? FileManager.default.copyItem(at: fancyProtocolSGFURL, to: url.appendingPathComponent("FancyProtocol.symbols.json")) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -856,7 +856,7 @@ class RenderNodeTranslatorTests: XCTestCase { func loadRenderNode(at path: String, in bundleURL: URL) throws -> RenderNode { let (_, bundle, context) = try loadBundle(from: bundleURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -865,7 +865,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testAutomaticTaskGroupTopicsAreSorted() throws { let (bundle, context) = try testBundleAndContext(named: "DefaultImplementations") - let structReference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) + let structReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) let structNode = try context.entity(with: structReference) let symbol = try XCTUnwrap(structNode.semantic as? Symbol) @@ -899,7 +899,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -927,7 +927,7 @@ class RenderNodeTranslatorTests: XCTestCase { // First verify that `SideKit` page does not contain render reference to `SideKit/SideClass/Element`. let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -947,7 +947,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -961,7 +961,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -991,7 +991,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1015,7 +1015,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testNestedSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1046,7 +1046,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceTrimsIndentation() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1072,7 +1072,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRowAndColumn() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1101,7 +1101,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSmall() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1129,7 +1129,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTabNavigator() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/BestBook/TabNavigatorArticle", sourceLanguage: .swift ) @@ -1166,7 +1166,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRenderNodeMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1242,7 +1242,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testPageColorMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1258,7 +1258,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTitleHeadingMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1340,7 +1340,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) @@ -1433,7 +1433,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) diff --git a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift index e57db9699..921b80b76 100644 --- a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift +++ b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift @@ -128,7 +128,7 @@ class SampleDownloadTests: XCTestCase { private func renderNodeFromSampleBundle(at referencePath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: "SampleBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: referencePath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index 5d33f20aa..983930800 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -87,7 +87,7 @@ class TermListTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: ["com.external.testbundle": resolver]) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -161,7 +161,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - term First term : A paragraph that @@ -204,7 +204,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - Not a term list, and diff --git a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift index 10d5df568..25ad3d776 100644 --- a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift @@ -47,11 +47,11 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertEqual(1, context.articleSymbolMentions.mentions.count) let mentioningArticle = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift) let mentionedSymbol = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) @@ -68,7 +68,7 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertTrue(context.articleSymbolMentions.mentions.isEmpty) let mentionedSymbol = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 910156632..aeda13f54 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -89,7 +89,7 @@ class DoxygenTests: XCTestCase { ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) // Verify the expected content in the in-memory model let node = try context.entity(with: reference) diff --git a/Tests/SwiftDocCTests/Semantics/VideoMediaTests.swift b/Tests/SwiftDocCTests/Semantics/VideoMediaTests.swift index cf8bec872..d351ce20a 100644 --- a/Tests/SwiftDocCTests/Semantics/VideoMediaTests.swift +++ b/Tests/SwiftDocCTests/Semantics/VideoMediaTests.swift @@ -322,7 +322,7 @@ class VideoMediaTests: XCTestCase { var problems = [Problem]() let video = VideoMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Semantics/VolumeTests.swift b/Tests/SwiftDocCTests/Semantics/VolumeTests.swift index 9e339576b..3b1647bad 100644 --- a/Tests/SwiftDocCTests/Semantics/VolumeTests.swift +++ b/Tests/SwiftDocCTests/Semantics/VolumeTests.swift @@ -102,7 +102,7 @@ class VolumeTests: XCTestCase { let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) diff --git a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift index dc49aa638..b28302d21 100644 --- a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift +++ b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift @@ -121,7 +121,7 @@ extension XCTestCase { func renderNode(atPath path: String, fromTestBundleNamed testBundleName: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: testBundleName) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return try XCTUnwrap(translator.visit(node.semantic) as? RenderNode) } @@ -273,7 +273,7 @@ extension XCTestCase { context: context, bundle: bundle, identifier: ResolvedTopicReference( - bundleIdentifier: bundle.identifier, + bundleIdentifier: bundle.id.rawValue, path: "/test-path-123", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift index 848be40d5..69759193a 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift @@ -29,7 +29,7 @@ class ConvertActionIndexerTests: XCTestCase { let renderNode = try converter.convert(context.entity(with: reference)) let tempIndexURL = try createTemporaryDirectory(named: "index") - let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.identifier) + let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.id.rawValue) indexer.index(renderNode) XCTAssertTrue(indexer.finalize(emitJSON: false, emitLMDB: false).isEmpty) let treeDump = try XCTUnwrap(indexer.dumpTree()) @@ -54,7 +54,7 @@ class ConvertActionIndexerTests: XCTestCase { let renderNode2 = try converter.convert(context.entity(with: reference2)) let tempIndexURL = try createTemporaryDirectory(named: "index") - let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.identifier) + let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.id.rawValue) indexer.index(renderNode1) indexer.index(renderNode2) XCTAssertTrue(indexer.finalize(emitJSON: false, emitLMDB: false).isEmpty) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index 9830a8321..8951e5da0 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -2853,7 +2853,7 @@ class ConvertActionTests: XCTestCase { let bundle = try XCTUnwrap(context.bundle, "Should have registered the generated test bundle.") XCTAssertEqual(bundle.displayName, "MyKit") - XCTAssertEqual(bundle.identifier, "MyKit") + XCTAssertEqual(bundle.id, "MyKit") } func testConvertWithoutBundleErrorsForMultipleModulesSymbolGraph() async throws { @@ -2931,7 +2931,7 @@ class ConvertActionTests: XCTestCase { let bundle = try XCTUnwrap(context.bundle, "Should have registered the generated test bundle.") XCTAssertEqual(bundle.displayName, "Something") - XCTAssertEqual(bundle.identifier, "com.example.test") + XCTAssertEqual(bundle.id, "com.example.test") } private func uniformlyPrintDiagnosticMessages(_ problems: [Problem]) -> String { diff --git a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift index f3a30eb64..59cc676b2 100644 --- a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift @@ -47,7 +47,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { let resolver = try OutOfProcessReferenceResolver(processLocation: executableLocation, errorOutputHandler: { errorMessage in XCTFail("No error output is expected for this test executable. Got:\n\(errorMessage)") }) - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle") + XCTAssertEqual(resolver.id, "com.test.bundle") #endif } @@ -88,7 +88,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { ) let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle") + XCTAssertEqual(resolver.id, "com.test.bundle") // Resolve the reference let unresolved = TopicReference.unresolved( @@ -197,7 +197,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - bundleIdentifier: "com.test.bundle", + id: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) @@ -267,7 +267,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle") + XCTAssertEqual(resolver.id, "com.test.bundle") // Resolve the symbol let (_, entity) = try XCTUnwrap(resolver.symbolReferenceAndEntity(withPreciseIdentifier: "abc123"), "Unexpectedly failed to resolve symbol") @@ -393,7 +393,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - bundleIdentifier: "com.test.bundle", + id: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) @@ -423,14 +423,14 @@ class OutOfProcessReferenceResolverTests: XCTestCase { XCTAssertEqual(errorMessage, "Some error output\n") didReadErrorOutputExpectation.fulfill() }) - XCTAssertEqual(resolver?.bundleIdentifier, "com.test.bundle") + XCTAssertEqual(resolver?.id, "com.test.bundle") wait(for: [didReadErrorOutputExpectation], timeout: 20.0) #endif } func assertForwardsResolverErrors(resolver: OutOfProcessReferenceResolver, file: StaticString = #file, line: UInt = #line) throws { - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle", file: file, line: line) + XCTAssertEqual(resolver.id, "com.test.bundle", file: file, line: line) let resolverResult = resolver.resolve(.unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://com.test.bundle/something")!))) guard case .failure(_, let error) = resolverResult else { XCTFail("Encountered an unexpected type of error.", file: file, line: line) @@ -495,7 +495,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) let resolver = try OutOfProcessReferenceResolver( - bundleIdentifier: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id") + id: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id") try assertForwardsResolverErrors(resolver: resolver) } @@ -674,7 +674,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { XCTAssert(FileManager.default.isExecutableFile(atPath: executableLocation.path)) let resolver = try OutOfProcessReferenceResolver(processLocation: executableLocation, errorOutputHandler: { _ in }) - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle") + XCTAssertEqual(resolver.id, "com.test.bundle") XCTAssertThrowsError(try resolver.resolveInformationForTopicURL(URL(string: "doc://com.test.bundle/something")!)) { guard case OutOfProcessReferenceResolver.Error.executableSentBundleIdentifierAgain = $0 else { @@ -720,7 +720,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { ) let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.bundleIdentifier, "com.test.bundle", file: file, line: line) + XCTAssertEqual(resolver.id, "com.test.bundle", file: file, line: line) // Resolve the reference let unresolved = TopicReference.unresolved( @@ -826,7 +826,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - bundleIdentifier: "com.test.bundle", + id: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) diff --git a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift index 6ff7276a4..96d875eb7 100644 --- a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift @@ -57,7 +57,7 @@ class SemanticAnalyzerTests: XCTestCase { func testDoNotCrashOnInvalidContent() throws { let (bundle, context) = try loadBundle(catalog: catalogHierarchy) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/Oops", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/Oops", sourceLanguage: .swift))) } func testWarningsAboutDirectiveSupport() throws { diff --git a/Tests/SwiftDocCUtilitiesTests/Utility/TestFileSystemTests.swift b/Tests/SwiftDocCUtilitiesTests/Utility/TestFileSystemTests.swift index c40c49674..af4318698 100644 --- a/Tests/SwiftDocCUtilitiesTests/Utility/TestFileSystemTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/Utility/TestFileSystemTests.swift @@ -331,7 +331,7 @@ class TestFileSystemTests: XCTestCase { let (bundle, _) = try DocumentationContext.InputsProvider(fileManager: fs) .inputsAndDataProvider(startingPoint: URL(fileURLWithPath: "/"), options: .init()) XCTAssertEqual(bundle.displayName, "DisplayName", "Display name is read from Info.plist") - XCTAssertEqual(bundle.identifier, "com.example", "Identifier is read from Info.plist") + XCTAssertEqual(bundle.id, "com.example", "Identifier is read from Info.plist") } do { From 399ed9a23ec61468c9b7e61b5b89f8168c5408fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 14:16:50 +0200 Subject: [PATCH 06/17] Use new Identifier type in `[Unresolved|Resolved]TopicReference` --- .../Infrastructure/DocumentationContext.swift | 6 +- Sources/SwiftDocC/Model/Identifier.swift | 80 ++++++++++++------- .../Converter/RenderNodeCodableTests.swift | 4 +- .../Indexing/NavigatorIndexTests.swift | 6 +- .../DocumentationContextTests.swift | 8 +- .../Model/IdentifierTests.swift | 16 ++-- 6 files changed, 69 insertions(+), 51 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index 52cd38e2c..f8cb69f46 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -328,7 +328,7 @@ public class DocumentationContext { self._configuration = configuration self.linkResolver = LinkResolver(dataProvider: dataProvider) - ResolvedTopicReference.enableReferenceCaching(for: bundle.id.rawValue) + ResolvedTopicReference.enableReferenceCaching(for: bundle.id) try register(bundle) } @@ -341,7 +341,7 @@ public class DocumentationContext { public func dataProvider(_ dataProvider: DocumentationContextDataProvider, didAddBundle bundle: DocumentationBundle) throws { try benchmark(wrap: Benchmark.Duration(id: "bundle-registration")) { // Enable reference caching for this documentation bundle. - ResolvedTopicReference.enableReferenceCaching(for: bundle.identifier) + ResolvedTopicReference.enableReferenceCaching(for: bundle.id) try self.register(bundle) } @@ -358,7 +358,7 @@ public class DocumentationContext { // Purge the reference cache for this bundle and disable reference caching for // this bundle moving forward. - ResolvedTopicReference.purgePool(for: bundle.identifier) + ResolvedTopicReference.purgePool(for: bundle.id) unregister(bundle) } diff --git a/Sources/SwiftDocC/Model/Identifier.swift b/Sources/SwiftDocC/Model/Identifier.swift index 8e50e4a1a..557637f0c 100644 --- a/Sources/SwiftDocC/Model/Identifier.swift +++ b/Sources/SwiftDocC/Model/Identifier.swift @@ -140,7 +140,7 @@ extension TopicReferenceResolutionErrorInfo { /// > Important: This type has copy-on-write semantics and wraps an underlying class to store /// > its data. public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomStringConvertible { - typealias ReferenceBundleIdentifier = String + typealias ReferenceBundleIdentifier = DocumentationBundle.Identifier private struct ReferenceKey: Hashable { var path: String var fragment: String? @@ -151,16 +151,16 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString private static var sharedPool = Synchronized([ReferenceBundleIdentifier: [ReferenceKey: ResolvedTopicReference]]()) /// Clears cached references belonging to the bundle with the given identifier. - /// - Parameter bundleIdentifier: The identifier of the bundle to which the method should clear belonging references. - static func purgePool(for bundleIdentifier: String) { - sharedPool.sync { $0.removeValue(forKey: bundleIdentifier) } + /// - Parameter id: The identifier of the bundle to which the method should clear belonging references. + static func purgePool(for id: ReferenceBundleIdentifier) { + sharedPool.sync { $0.removeValue(forKey: id) } } /// Enables reference caching for any identifiers created with the given bundle identifier. - static func enableReferenceCaching(for bundleIdentifier: ReferenceBundleIdentifier) { + static func enableReferenceCaching(for id: ReferenceBundleIdentifier) { sharedPool.sync { sharedPool in - if !sharedPool.keys.contains(bundleIdentifier) { - sharedPool[bundleIdentifier] = [:] + if !sharedPool.keys.contains(id) { + sharedPool[id] = [:] } } } @@ -176,9 +176,14 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// The storage for the resolved topic reference's state. let _storage: Storage - /// The identifier of the bundle that owns this documentation topic. + @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") public var bundleIdentifier: String { - return _storage.bundleIdentifier + id.rawValue + } + + /// The identifier of the bundle that owns this documentation topic. + public var id: DocumentationBundle.Identifier { + _storage.id } /// The absolute path from the bundle to this topic, delimited by `/`. @@ -207,31 +212,39 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } /// - Note: The `path` parameter is escaped to a path readable string. - public init(bundleIdentifier: String, path: String, fragment: String? = nil, sourceLanguage: SourceLanguage) { - self.init(bundleIdentifier: bundleIdentifier, path: path, fragment: fragment, sourceLanguages: [sourceLanguage]) + public init(id: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguage: SourceLanguage) { + self.init(id: id, path: path, fragment: fragment, sourceLanguages: [sourceLanguage]) } - public init(bundleIdentifier: String, path: String, fragment: String? = nil, sourceLanguages: Set) { + public init(id: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguages: Set) { self.init( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: urlReadablePath(path), urlReadableFragment: fragment.map(urlReadableFragment(_:)), sourceLanguages: sourceLanguages ) } + @available(*, deprecated, renamed: "init(id:path:fragment:sourceLanguage:)", message: "Use 'init(id:path:fragment:sourceLanguage:)' instead. This deprecated API will be removed after 6.2 is released") + public init(bundleIdentifier: String, path: String, fragment: String? = nil, sourceLanguage: SourceLanguage) { + self.init(bundleIdentifier: bundleIdentifier, path: path, fragment: fragment, sourceLanguages: [sourceLanguage]) + } + @available(*, deprecated, renamed: "init(id:path:fragment:sourceLanguages:)", message: "Use 'init(id:path:fragment:sourceLanguages:)' instead. This deprecated API will be removed after 6.2 is released") + public init(bundleIdentifier: String, path: String, fragment: String? = nil, sourceLanguages: Set) { + self.init(id: .init(rawValue: bundleIdentifier), path: path, fragment: fragment, sourceLanguages: sourceLanguages) + } - private init(bundleIdentifier: String, urlReadablePath: String, urlReadableFragment: String? = nil, sourceLanguages: Set) { + private init(id: DocumentationBundle.Identifier, urlReadablePath: String, urlReadableFragment: String? = nil, sourceLanguages: Set) { precondition(!sourceLanguages.isEmpty, "ResolvedTopicReference.sourceLanguages cannot be empty") // Check for a cached instance of the reference let key = ReferenceKey(path: urlReadablePath, fragment: urlReadableFragment, sourceLanguages: sourceLanguages) - let cached = Self.sharedPool.sync { $0[bundleIdentifier]?[key] } + let cached = Self.sharedPool.sync { $0[id]?[key] } if let resolved = cached { self = resolved return } _storage = Storage( - bundleIdentifier: bundleIdentifier, + id: id, path: urlReadablePath, fragment: urlReadableFragment, sourceLanguages: sourceLanguages @@ -240,7 +253,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString // Cache the reference Self.sharedPool.sync { sharedPool in // If we have a shared pool for this bundle identifier, cache the reference - sharedPool[bundleIdentifier]?[key] = self + sharedPool[id]?[key] = self } } @@ -285,7 +298,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString decoder.registerReferences([url.absoluteString]) - self.init(bundleIdentifier: bundleIdentifier, path: url.path, fragment: url.fragment, sourceLanguage: interfaceLanguage) + self.init(id: .init(rawValue: bundleIdentifier), path: url.path, fragment: url.fragment, sourceLanguage: interfaceLanguage) } /// Creates a new topic reference with the given fragment. @@ -304,7 +317,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// - Returns: The resulting topic reference. public func withFragment(_ fragment: String?) -> ResolvedTopicReference { let newReference = ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, path: path, fragment: fragment.map(urlReadableFragment), sourceLanguages: sourceLanguages @@ -321,7 +334,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// - Returns: The resulting topic reference. public func appendingPath(_ path: String) -> ResolvedTopicReference { let newReference = ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: url.appendingPathComponent(urlReadablePath(path), isDirectory: false).path, sourceLanguages: sourceLanguages ) @@ -342,7 +355,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } let newPath = url.appendingPathComponent(referencePath, isDirectory: false).path let newReference = ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: newPath, urlReadableFragment: reference.fragment.map(urlReadableFragment), sourceLanguages: sourceLanguages @@ -354,7 +367,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString public func removingLastPathComponent() -> ResolvedTopicReference { let newPath = String(pathComponents.dropLast().joined(separator: "/").dropFirst()) let newReference = ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: newPath, urlReadableFragment: fragment, sourceLanguages: sourceLanguages @@ -374,7 +387,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } return ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: path, urlReadableFragment: fragment, sourceLanguages: combinedSourceLanguages @@ -391,7 +404,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } return ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, + id: id, urlReadablePath: path, urlReadableFragment: fragment, sourceLanguages: sourceLanguages @@ -447,7 +460,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// /// This is a reference type which allows ``ResolvedTopicReference`` to have copy-on-write behavior. class Storage { - let bundleIdentifier: String + let id: DocumentationBundle.Identifier let path: String let fragment: String? let sourceLanguages: Set @@ -460,20 +473,20 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString let absoluteString: String init( - bundleIdentifier: String, + id: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguages: Set ) { - self.bundleIdentifier = bundleIdentifier + self.id = id self.path = path self.fragment = fragment self.sourceLanguages = sourceLanguages - self.identifierPathAndFragment = "\(bundleIdentifier)\(path)\(fragment ?? "")" + self.identifierPathAndFragment = "\(id)\(path)\(fragment ?? "")" var components = URLComponents() components.scheme = ResolvedTopicReference.urlScheme - components.host = bundleIdentifier + components.host = id.rawValue components.path = path components.fragment = fragment self.url = components.url! @@ -515,9 +528,14 @@ public struct UnresolvedTopicReference: Hashable, CustomStringConvertible { /// The URL as originally spelled. public let topicURL: ValidatedURL - /// The bundle identifier, if one was provided in the host name component of the original URL. + @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") public var bundleIdentifier: String? { - return topicURL.components.host + id?.rawValue + } + + /// The bundle identifier, if one was provided in the host name component of the original URL. + public var id: DocumentationBundle.Identifier? { + topicURL.components.host.map { .init(rawValue: $0) } } /// The path of the unresolved reference. diff --git a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift index d94b9d335..f30552aaa 100644 --- a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift +++ b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift @@ -146,10 +146,10 @@ class RenderNodeCodableTests: XCTestCase { subdirectory: "Test Resources" )! - let bundleID = #function + let bundleID: DocumentationBundle.Identifier = #function let renderNodeWithUniqueBundleID = try String(contentsOf: exampleRenderNodeJSON) - .replacingOccurrences(of: "org.swift.docc.example", with: bundleID) + .replacingOccurrences(of: "org.swift.docc.example", with: bundleID.rawValue) _ = try JSONDecoder().decode(RenderNode.self, from: Data(renderNodeWithUniqueBundleID.utf8)) diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 31cdc61ac..55e992110 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -243,18 +243,18 @@ Root } func testLoadingNavigatorIndexDoesNotCacheReferences() throws { - let uniqueTestBundleIdentifier = #function + let uniqueTestBundleIdentifier: DocumentationBundle.Identifier = #function let targetURL = try createTemporaryDirectory() let indexURL = targetURL.appendingPathComponent("nav.index") - let root = generateSmallTree(bundleIdentifier: uniqueTestBundleIdentifier) + let root = generateSmallTree(bundleIdentifier: uniqueTestBundleIdentifier.rawValue) let original = NavigatorTree(root: root) try original.write(to: indexURL) _ = try NavigatorTree.read( from: indexURL, - bundleIdentifier: uniqueTestBundleIdentifier, + bundleIdentifier: uniqueTestBundleIdentifier.rawValue, atomically: true ) diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 65ec10847..4aa275a32 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -2705,14 +2705,14 @@ let expected = """ } func testContextCachesReferences() throws { - let bundleID = #function + let bundleID: DocumentationBundle.Identifier = #function // Verify there is no pool bucket for the bundle we're about to test XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) let (_, _, _) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { rootURL in let infoPlistURL = rootURL.appendingPathComponent("Info.plist", isDirectory: false) try! String(contentsOf: infoPlistURL) - .replacingOccurrences(of: "org.swift.docc.example", with: bundleID) + .replacingOccurrences(of: "org.swift.docc.example", with: bundleID.rawValue) .write(to: infoPlistURL, atomically: true, encoding: .utf8) }) @@ -2722,13 +2722,13 @@ let expected = """ let beforeCount = try XCTUnwrap(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Verify a given identifier exists in the pool by creating it and verifying it wasn't added to the pool - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) // Verify create the reference above did not add to the cache XCTAssertEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Create a new reference for the same bundle that was not loaded with the context - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) // Verify creating a new reference added to the ones loaded with the context XCTAssertNotEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) diff --git a/Tests/SwiftDocCTests/Model/IdentifierTests.swift b/Tests/SwiftDocCTests/Model/IdentifierTests.swift index 700b8228e..be95cbb79 100644 --- a/Tests/SwiftDocCTests/Model/IdentifierTests.swift +++ b/Tests/SwiftDocCTests/Model/IdentifierTests.swift @@ -65,7 +65,7 @@ class IdentifierTests: XCTestCase { } func testReusingReferences() { - let bundleID = #function + let bundleID: DocumentationBundle.Identifier = #function XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "Cache for this bundle shouldn't exist because caching is not enabled by default") // Add one reference @@ -73,15 +73,15 @@ class IdentifierTests: XCTestCase { XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") // Add the same reference repeatedly - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/page", sourceLanguage: .swift) - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should still only have one cached reference because the same reference was created repeatedly") // Add another reference - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/other-page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/other-page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 2, "Should have cached another reference because two different references with this bundle identifier has been created") // Purge and repeat @@ -91,15 +91,15 @@ class IdentifierTests: XCTestCase { ResolvedTopicReference.enableReferenceCaching(for: bundleID) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") } func testReferencesAreNotCachedByDefault() { - let bundleID = #function + let bundleID: DocumentationBundle.Identifier = #function XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "References for this bundle shouldn't exist because caching is not enabled by default") - _ = ResolvedTopicReference(bundleIdentifier: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "After creating a reference in this bundle, references still shouldn't exist because caching is not enabled by default") } From a7310b736ed5df71080795096833a3b04bc62541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 15:41:45 +0200 Subject: [PATCH 07/17] Update code to not use deprecated topic reference `bundleIdentifier` property --- .../Convert/ConvertService.swift | 2 +- .../Indexing/Navigator/NavigatorIndex.swift | 2 +- .../Infrastructure/DocumentationBundle.swift | 6 +- .../Infrastructure/DocumentationContext.swift | 52 +++-- .../Infrastructure/DocumentationCurator.swift | 2 +- .../OutOfProcessReferenceResolver.swift | 6 +- .../ExternalPathHierarchyResolver.swift | 6 +- .../Link Resolution/LinkResolver.swift | 12 +- .../PathHierarchyBasedLinkResolver.swift | 5 +- .../GeneratedDocumentationTopics.swift | 2 +- .../ResolvedTopicReference+Symbol.swift | 4 +- .../LinkTargets/LinkDestinationSummary.swift | 4 +- .../DocumentationContentRenderer.swift | 6 +- .../RenderHierarchyTranslator.swift | 2 +- .../Model/Rendering/RenderContext.swift | 4 +- .../Rendering/RenderNodeTranslator.swift | 2 +- .../FilesAndFolders.swift | 2 +- .../Action/Actions/Merge/MergeAction.swift | 2 +- .../Benchmark/ExternalTopicsHashTests.swift | 20 +- .../Benchmark/TopicAnchorHashTests.swift | 4 +- .../Benchmark/TopicGraphHashTests.swift | 6 +- .../Converter/RenderNodeCodableTests.swift | 6 +- ...nderNodeVariantOverridesApplierTests.swift | 6 +- .../TopicRenderReferenceEncoderTests.swift | 8 +- .../Diagnostics/DiagnosticTests.swift | 4 +- .../Indexing/IndexingTests.swift | 12 +- .../Indexing/NavigatorIndexTests.swift | 8 +- .../Infrastructure/AnchorSectionTests.swift | 20 +- .../AutoCapitalizationTests.swift | 6 +- .../AutomaticCurationTests.swift | 40 ++-- .../Infrastructure/BundleDiscoveryTests.swift | 6 +- ...ext+MixedLanguageLinkResolutionTests.swift | 4 +- .../DocumentationContext+RootPageTests.swift | 2 +- .../DocumentationContextTests.swift | 180 +++++++++--------- .../DocumentationCuratorTests.swift | 36 ++-- .../ExternalPathHierarchyResolverTests.swift | 10 +- .../ExternalReferenceResolverTests.swift | 98 +++++----- .../DocumentationInputsProviderTests.swift | 4 +- .../Infrastructure/NodeTagsTests.swift | 6 +- .../NodeURLGeneratorTests.swift | 10 +- .../Infrastructure/PathHierarchyTests.swift | 2 +- .../PresentationURLGeneratorTests.swift | 8 +- .../ReferenceResolverTests.swift | 40 ++-- .../ResolvedTopicReferenceTests.swift | 12 +- ...SymbolGraphRelationshipsBuilderTests.swift | 10 +- .../TestExternalReferenceResolvers.swift | 6 +- .../Infrastructure/TopicGraphTests.swift | 2 +- .../LinkDestinationSummaryTests.swift | 26 +-- .../Model/DocumentationNodeTests.swift | 4 +- .../Model/IdentifierTests.swift | 34 ++-- .../Model/LineHighlighterTests.swift | 2 +- .../ParametersAndReturnValidatorTests.swift | 14 +- ...opertyListPossibleValuesSectionTests.swift | 8 +- .../Model/RenderContentMetadataTests.swift | 16 +- .../RenderHierarchyTranslatorTests.swift | 6 +- .../Model/RenderNodeDiffingBundleTests.swift | 24 +-- .../Model/RenderNodeSerializationTests.swift | 12 +- .../Model/ResourceReferenceTests.swift | 4 +- .../SemaToRenderNodeMultiLanguageTests.swift | 2 +- .../Model/SemaToRenderNodeTests.swift | 134 ++++++------- .../SwiftDocCTests/Model/TaskGroupTests.swift | 4 +- .../Rendering/AutomaticSeeAlsoTests.swift | 20 +- .../AvailabilityRenderOrderTests.swift | 2 +- .../ConstraintsRenderSectionTests.swift | 18 +- .../DeclarationsRenderSectionTests.swift | 12 +- .../Rendering/DefaultAvailabilityTests.swift | 16 +- .../DefaultCodeListingSyntaxTests.swift | 4 +- .../Rendering/DeprecationSummaryTests.swift | 16 +- .../DocumentationContentRendererTests.swift | 4 +- .../Rendering/ExternalLinkTitleTests.swift | 4 +- .../MentionsRenderSectionTests.swift | 6 +- .../Rendering/PageKindTests.swift | 4 +- .../Rendering/PlatformAvailabilityTests.swift | 16 +- .../Rendering/RESTSymbolsTests.swift | 2 +- ...enderBlockContent_ThematicBreakTests.swift | 6 +- .../RenderContentCompilerTests.swift | 6 +- .../Rendering/RenderMetadataTests.swift | 8 +- ...derNodeTranslatorSymbolVariantsTests.swift | 36 ++-- .../Rendering/RenderNodeTranslatorTests.swift | 70 +++---- .../SwiftDocCTests/Rendering/RoleTests.swift | 8 +- .../Rendering/SampleDownloadTests.swift | 4 +- .../Rendering/TermListTests.swift | 6 +- .../ArticleSymbolMentionsTests.swift | 10 +- .../Semantics/DoxygenTests.swift | 2 +- .../Semantics/TutorialArticleTests.swift | 8 +- .../Semantics/TutorialTests.swift | 8 +- .../Semantics/VideoMediaTests.swift | 4 +- .../Semantics/VolumeTests.swift | 4 +- .../XCTestCase+LoadingTestData.swift | 4 +- .../ConvertActionIndexerTests.swift | 6 +- .../ConvertActionTests.swift | 2 +- .../JSONEncodingRenderNodeWriterTests.swift | 2 +- .../SemanticAnalyzerTests.swift | 2 +- 93 files changed, 651 insertions(+), 656 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift index afd6ea808..7951f9b74 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift @@ -267,7 +267,7 @@ public struct ConvertService: DocumentationService { .compactMap { (value, isDocumentationExtensionContent) -> (ResolvedTopicReference, RenderReferenceStore.TopicContent)? in let (topicReference, article) = value - guard let bundle = context.bundle, bundle.id.rawValue == topicReference.bundleIdentifier else { return nil } + guard let bundle = context.bundle, bundle.id == topicReference.id else { return nil } let renderer = DocumentationContentRenderer(documentationContext: context, bundle: bundle) let documentationNodeKind: DocumentationNode.Kind = isDocumentationExtensionContent ? .unknownSymbol : .article diff --git a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift index c54c94506..d03a99f1d 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift @@ -438,7 +438,7 @@ extension ResolvedTopicReference { let normalizedPath = NodeURLGenerator.fileSafeReferencePath(self, lowercased: true) return NavigatorIndex.Identifier( - bundleIdentifier: bundleIdentifier.lowercased(), + bundleIdentifier: id.rawValue.lowercased(), path: "/" + normalizedPath, fragment: fragment, languageIdentifier: languageIdentifier diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift index f5b5beaea..794f81eef 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift @@ -127,9 +127,9 @@ public struct DocumentationBundle { self.customHeader = customHeader self.customFooter = customFooter self.themeSettings = themeSettings - self.rootReference = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: "/", sourceLanguage: .swift) - self.documentationRootReference = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) - self.tutorialTableOfContentsContainer = ResolvedTopicReference(bundleIdentifier: info.id.rawValue, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) + self.rootReference = ResolvedTopicReference(id: info.id, path: "/", sourceLanguage: .swift) + self.documentationRootReference = ResolvedTopicReference(id: info.id, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) + self.tutorialTableOfContentsContainer = ResolvedTopicReference(id: info.id, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) self.tutorialsContainerReference = tutorialTableOfContentsContainer.appendingPath(urlReadablePath(info.displayName)) self.articlesDocumentationRootReference = documentationRootReference.appendingPath(urlReadablePath(info.displayName)) } diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index f8cb69f46..23c1ecc0a 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -218,7 +218,7 @@ public class DocumentationContext { /// references for lookup. var documentationCache = LocalCache() /// The asset managers for each documentation bundle, keyed by the bundle's identifier. - var assetManagers = [BundleIdentifier: DataAssetManager]() + var assetManagers = [DocumentationBundle.Identifier: DataAssetManager]() /// A list of non-topic links that can be resolved. var nodeAnchorSections = [ResolvedTopicReference: AnchorSection]() @@ -914,7 +914,7 @@ public class DocumentationContext { let (url, analyzed) = analyzedDocument let path = NodeURLGenerator.pathForSemantic(analyzed, source: url, bundle: bundle) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) // Since documentation extensions' filenames have no impact on the URL of pages, there is no need to enforce unique filenames for them. // At this point we consider all articles with an H1 containing link a "documentation extension." @@ -1335,7 +1335,7 @@ public class DocumentationContext { let symbolPath = NodeURLGenerator.Path.documentation(path: url.components.path).stringValue let symbolReference = ResolvedTopicReference( - bundleIdentifier: reference.bundleIdentifier, + id: reference.id, path: symbolPath, fragment: nil, sourceLanguages: reference.sourceLanguages @@ -1776,11 +1776,11 @@ public class DocumentationContext { private func registerMiscResources(from bundle: DocumentationBundle) throws { let miscResources = Set(bundle.miscResourceURLs) - try assetManagers[bundle.id.rawValue, default: DataAssetManager()].register(data: miscResources) + try assetManagers[bundle.id, default: DataAssetManager()].register(data: miscResources) } - private func registeredAssets(withExtensions extensions: Set? = nil, inContexts contexts: [DataAsset.Context] = DataAsset.Context.allCases, forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - guard let resources = assetManagers[bundleIdentifier]?.storage.values else { + private func registeredAssets(withExtensions extensions: Set? = nil, inContexts contexts: [DataAsset.Context] = DataAsset.Context.allCases, forBundleID bundleID: DocumentationBundle.Identifier) -> [DataAsset] { + guard let resources = assetManagers[bundleID]?.storage.values else { return [] } return resources.filter { dataAsset in @@ -1801,7 +1801,7 @@ public class DocumentationContext { /// - Parameter bundleIdentifier: The identifier of the bundle to return image assets for. /// - Returns: A list of all the image assets for the given bundle. public func registeredImageAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: bundleIdentifier) + return registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } /// Returns a list of all the video assets that registered for a given `bundleIdentifier`. @@ -1809,7 +1809,7 @@ public class DocumentationContext { /// - Parameter bundleIdentifier: The identifier of the bundle to return video assets for. /// - Returns: A list of all the video assets for the given bundle. public func registeredVideoAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: bundleIdentifier) + return registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } /// Returns a list of all the download assets that registered for a given `bundleIdentifier`. @@ -1817,7 +1817,7 @@ public class DocumentationContext { /// - Parameter bundleIdentifier: The identifier of the bundle to return download assets for. /// - Returns: A list of all the download assets for the given bundle. public func registeredDownloadsAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: bundleIdentifier) + return registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } typealias Articles = [DocumentationContext.SemanticResult
] @@ -1932,7 +1932,7 @@ public class DocumentationContext { let title = articleResult.source.deletingPathExtension().lastPathComponent // Create a new root-looking reference let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: NodeURLGenerator.Path.documentation(path: title).stringValue, sourceLanguages: [DocumentationContext.defaultLanguage(in: nil /* article-only content has no source language information */)] ) @@ -1971,7 +1971,7 @@ public class DocumentationContext { let path = NodeURLGenerator.Path.documentation(path: title).stringValue let sourceLanguage = DocumentationContext.defaultLanguage(in: []) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguages: [sourceLanguage]) + let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguages: [sourceLanguage]) let graphNode = TopicGraph.Node(reference: reference, kind: .module, source: .external, title: title) topicGraph.addNode(graphNode) @@ -2036,7 +2036,7 @@ public class DocumentationContext { let defaultSourceLanguage = defaultLanguage(in: availableSourceLanguages) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: path, sourceLanguages: availableSourceLanguages // FIXME: Pages in article-only catalogs should not be inferred as "Swift" as a fallback @@ -2670,13 +2670,13 @@ public class DocumentationContext { Unregister a documentation bundle with this context and clear any cached resources associated with it. */ private func unregister(_ bundle: DocumentationBundle) { - let referencesToRemove = topicGraph.nodes.keys.filter { reference in - return reference.bundleIdentifier == bundle.id.rawValue + let referencesToRemove = topicGraph.nodes.keys.filter { + $0.id == bundle.id } for reference in referencesToRemove { - topicGraph.edges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.id.rawValue }) - topicGraph.reverseEdges[reference]?.removeAll(where: { $0.bundleIdentifier == bundle.id.rawValue }) + topicGraph.edges[reference]?.removeAll(where: { $0.id == bundle.id }) + topicGraph.reverseEdges[reference]?.removeAll(where: { $0.id == bundle.id }) topicGraph.nodes[reference] = nil } } @@ -2694,7 +2694,7 @@ public class DocumentationContext { */ public func resource(with identifier: ResourceReference, trait: DataTraitCollection = .init()) throws -> Data { guard let bundle, - let assetManager = assetManagers[identifier.bundleIdentifier], + let assetManager = assetManagers[DocumentationBundle.Identifier(rawValue: identifier.bundleIdentifier)], let asset = assetManager.allData(named: identifier.path) else { throw ContextError.notFound(identifier.url) } @@ -2706,7 +2706,7 @@ public class DocumentationContext { /// Returns true if a resource with the given identifier exists in the registered bundle. public func resourceExists(with identifier: ResourceReference, ofType expectedAssetType: AssetType? = nil) -> Bool { - guard let assetManager = assetManagers[identifier.bundleIdentifier] else { + guard let assetManager = assetManagers[DocumentationBundle.Identifier(rawValue: identifier.bundleIdentifier)] else { return false } @@ -2722,7 +2722,7 @@ public class DocumentationContext { } private func externalEntity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity? { - return configuration.externalDocumentationConfiguration.sources[reference.bundleIdentifier].map({ $0.entity(with: reference) }) + return configuration.externalDocumentationConfiguration.sources[reference.id.rawValue].map({ $0.entity(with: reference) }) ?? configuration.convertServiceConfiguration.fallbackResolver?.entityIfPreviouslyResolved(with: reference) } @@ -2888,8 +2888,7 @@ public class DocumentationContext { /// - asset: The new asset for this name. /// - parent: The topic where the asset is referenced. public func updateAsset(named name: String, asset: DataAsset, in parent: ResolvedTopicReference) { - let bundleIdentifier = parent.bundleIdentifier - assetManagers[bundleIdentifier]?.update(name: name, asset: asset) + assetManagers[parent.id]?.update(name: name, asset: asset) } /// Attempt to resolve an asset given its name and the topic it's referenced in. @@ -2900,12 +2899,11 @@ public class DocumentationContext { /// - type: A restriction for what type of asset to resolve. /// - Returns: The data that's associated with an image asset if it was found, otherwise `nil`. public func resolveAsset(named name: String, in parent: ResolvedTopicReference, withType type: AssetType? = nil) -> DataAsset? { - let bundleIdentifier = parent.bundleIdentifier - return resolveAsset(named: name, bundleIdentifier: bundleIdentifier, withType: type) + resolveAsset(named: name, bundleID: parent.id, withType: type) } - func resolveAsset(named name: String, bundleIdentifier: String, withType expectedType: AssetType?) -> DataAsset? { - if let localAsset = assetManagers[bundleIdentifier]?.allData(named: name) { + func resolveAsset(named name: String, bundleID: DocumentationBundle.Identifier, withType expectedType: AssetType?) -> DataAsset? { + if let localAsset = assetManagers[bundleID]?.allData(named: name) { if let expectedType { guard localAsset.hasVariant(withAssetType: expectedType) else { return nil @@ -2917,7 +2915,7 @@ public class DocumentationContext { if let fallbackAssetResolver = configuration.convertServiceConfiguration.fallbackResolver, let externallyResolvedAsset = fallbackAssetResolver.resolve(assetNamed: name) { - assetManagers[bundleIdentifier, default: DataAssetManager()] + assetManagers[bundleID, default: DataAssetManager()] .register(dataAsset: externallyResolvedAsset, forName: name) return externallyResolvedAsset } @@ -2945,7 +2943,7 @@ public class DocumentationContext { /// /// - Returns: The best matching storage key if it was found, otherwise `nil`. public func identifier(forAssetName name: String, in parent: ResolvedTopicReference) -> String? { - if let assetManager = assetManagers[parent.bundleIdentifier] { + if let assetManager = assetManagers[parent.id] { if let localName = assetManager.bestKey(forAssetName: name) { return localName } else if let fallbackAssetManager = configuration.convertServiceConfiguration.fallbackResolver { diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift index 4e14268ba..f3b646bcc 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift @@ -94,7 +94,7 @@ struct DocumentationCurator { let sourceArticlePath = NodeURLGenerator.Path.article(bundleName: bundle.displayName, articleName: articleFilename).stringValue let reference = ResolvedTopicReference( - bundleIdentifier: resolved.bundleIdentifier, + id: resolved.id, path: sourceArticlePath, sourceLanguages: resolved.sourceLanguages) diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index 3141807d0..e504b9a13 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -115,7 +115,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE return resolved case let .unresolved(unresolvedReference): - guard unresolvedReference.bundleIdentifier == id.rawValue else { + guard unresolvedReference.id == id else { fatalError(""" Attempted to resolve a local reference externally: \(unresolvedReference.description.singleQuoted). DocC should never pass a reference to an external resolver unless it matches that resolver's bundle identifier. @@ -147,7 +147,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE guard let resolvedInformation = try? resolveInformationForSymbolIdentifier(preciseIdentifier) else { return nil } let reference = ResolvedTopicReference( - bundleIdentifier: "com.externally.resolved.symbol", + id: "com.externally.resolved.symbol", path: "/\(preciseIdentifier)", sourceLanguages: sourceLanguages(for: resolvedInformation) ) @@ -255,7 +255,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE private func resolvedReference(for resolvedInformation: ResolvedInformation) -> ResolvedTopicReference { return ResolvedTopicReference( - bundleIdentifier: id.rawValue, + id: id, path: resolvedInformation.url.path, fragment: resolvedInformation.url.fragment, sourceLanguages: sourceLanguages(for: resolvedInformation) diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift index 431ea3298..dcc16d7e8 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift @@ -98,7 +98,7 @@ final class ExternalPathHierarchyResolver { else { return nil } - return ResolvedTopicReference(bundleIdentifier: bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift) + return ResolvedTopicReference(id: .init(rawValue: bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift) } let dependencies = RenderReferenceDependencies( topicReferences: topicReferences, @@ -126,7 +126,7 @@ final class ExternalPathHierarchyResolver { symbols.reserveCapacity(linkDestinationSummaries.count) for entity in linkDestinationSummaries { let reference = ResolvedTopicReference( - bundleIdentifier: entity.referenceURL.host!, + id: .init(rawValue: entity.referenceURL.host!), path: entity.referenceURL.path, fragment: entity.referenceURL.fragment, sourceLanguage: entity.language @@ -150,7 +150,7 @@ final class ExternalPathHierarchyResolver { continue } let identifier = identifiers[index] - self.resolvedReferences[identifier] = ResolvedTopicReference(bundleIdentifier: fileRepresentation.bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift) + self.resolvedReferences[identifier] = ResolvedTopicReference(id: .init(rawValue: fileRepresentation.bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift) } } // Finally, the Identifier -> Symbol mapping can be constructed by iterating over the nodes and looking up the reference for each USR. diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index c56c037a3..552205e55 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -92,10 +92,10 @@ public class LinkResolver { } // Check if this is a link to an external documentation source that should have previously been resolved in `DocumentationContext.preResolveExternalLinks(...)` - if let bundleID = unresolvedReference.bundleIdentifier, - !context._registeredBundles.contains(where: { $0.id.rawValue == bundleID || urlReadablePath($0.displayName) == bundleID }) + if let bundleID = unresolvedReference.id, + !context._registeredBundles.contains(where: { $0.id == bundleID || urlReadablePath($0.displayName) == bundleID.rawValue }) { - return .failure(unresolvedReference, TopicReferenceResolutionErrorInfo("No external resolver registered for \(bundleID.singleQuoted).")) + return .failure(unresolvedReference, TopicReferenceResolutionErrorInfo("No external resolver registered for '\(bundleID)'.")) } do { @@ -169,10 +169,10 @@ private final class FallbackResolverBasedLinkResolver { private func resolve(_ unresolvedReference: UnresolvedTopicReference, in parent: ResolvedTopicReference, fromSymbolLink isCurrentlyResolvingSymbolLink: Bool, context: DocumentationContext) -> TopicReferenceResolutionResult? { // Check if a fallback reference resolver should resolve this - let referenceBundleIdentifier = unresolvedReference.bundleIdentifier ?? parent.bundleIdentifier + let referenceID = unresolvedReference.id ?? parent.id guard let fallbackResolver = context.configuration.convertServiceConfiguration.fallbackResolver, // This uses an underscored internal variant of `registeredBundles` to avoid deprecation warnings and remain compatible with legacy data providers. - let knownBundleIdentifier = context._registeredBundles.first(where: { $0.id.rawValue == referenceBundleIdentifier || urlReadablePath($0.displayName) == referenceBundleIdentifier })?.id.rawValue, + let knownBundleIdentifier = context._registeredBundles.first(where: { $0.id == referenceID || urlReadablePath($0.displayName) == referenceID.rawValue })?.id.rawValue, fallbackResolver.bundleIdentifier == knownBundleIdentifier else { return nil @@ -184,7 +184,7 @@ private final class FallbackResolverBasedLinkResolver { var allCandidateURLs = [URL]() let alreadyResolved = ResolvedTopicReference( - bundleIdentifier: referenceBundleIdentifier, + id: referenceID, path: unresolvedReference.path.prependingLeadingSlash, fragment: unresolvedReference.topicURL.components.fragment, sourceLanguages: parent.sourceLanguages diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift index 104ad6d99..29b395e62 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift @@ -26,9 +26,10 @@ final class PathHierarchyBasedLinkResolver { /// Remove all matches from a given documentation bundle from the link resolver. func unregisterBundle(identifier: BundleIdentifier) { + let identifier = DocumentationBundle.Identifier(rawValue: identifier) var newMap = BidirectionalMap() for (id, reference) in resolvedReferenceMap { - if reference.bundleIdentifier == identifier { + if reference.id == identifier { pathHierarchy.removeNodeWithID(id) } else { newMap[id] = reference @@ -301,7 +302,7 @@ final class PathHierarchyBasedLinkResolver { } return ResolvedTopicReference( - bundleIdentifier: bundle.documentationRootReference.bundleIdentifier, + id: bundle.documentationRootReference.id, path: NodeURLGenerator.Path.documentationFolder + path, sourceLanguages: symbol.sourceLanguages ) diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift index 14036f87a..d1cd65535 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift @@ -107,7 +107,7 @@ enum GeneratedDocumentationTopics { // Create the collection topic reference let collectionReference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: NodeURLGenerator.Path.documentationCuration( parentPath: parent.path, articleName: title diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift index de42d0ac4..4f121df98 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -20,7 +20,7 @@ extension ResolvedTopicReference { let path = symbolReference.path.isEmpty ? "" : "/" + symbolReference.path self.init( - bundleIdentifier: bundle.documentationRootReference.bundleIdentifier, + id: bundle.documentationRootReference.id, path: bundle.documentationRootReference.appendingPath(moduleName + path).path, fragment: nil, sourceLanguages: symbolReference.interfaceLanguages diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index 80df9f863..fc06ae820 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -311,7 +311,7 @@ public extension DocumentationNode { renderNode: RenderNode, includeTaskGroups: Bool = true ) -> [LinkDestinationSummary] { - guard let bundle = context.bundle, bundle.id.rawValue == reference.bundleIdentifier else { + guard let bundle = context.bundle, bundle.id == reference.id else { // Don't return anything for external references that don't have a bundle in the context. return [] } diff --git a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift index f81ccbc0d..3c8e02f88 100644 --- a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift +++ b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift @@ -329,7 +329,7 @@ public class DocumentationContentRenderer { if kind == .section { // Sections don't have their own abstract so take the one of the container symbol. let containerReference = ResolvedTopicReference( - bundleIdentifier: reference.bundleIdentifier, + id: reference.id, path: reference.path, sourceLanguages: reference.sourceLanguages ) @@ -502,14 +502,14 @@ public class DocumentationContentRenderer { } // For external links, verify they've resolved successfully and return `nil` otherwise. - if linkHost != reference.bundleIdentifier { + if linkHost != reference.id.rawValue { if let url = ValidatedURL(destination), case .success(let externalReference) = documentationContext.externallyResolvedLinks[url] { return externalReference } return nil } return ResolvedTopicReference( - bundleIdentifier: reference.bundleIdentifier, + id: reference.id, path: destination.path, sourceLanguages: node.availableSourceLanguages ) diff --git a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift index b3aee8629..daceacfa8 100644 --- a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift @@ -161,7 +161,7 @@ struct RenderHierarchyTranslator { if let tutorial = (try? context.entity(with: tutorialReference).semantic) as? Tutorial, let assessments = tutorial.assessments, !assessments.questions.isEmpty { // Add hardcoded assessment section. - let assessmentReference = ResolvedTopicReference(bundleIdentifier: tutorialReference.bundleIdentifier, path: tutorialReference.path, fragment: RenderHierarchyTranslator.assessmentsAnchor, sourceLanguage: .swift) + let assessmentReference = ResolvedTopicReference(id: tutorialReference.id, path: tutorialReference.path, fragment: RenderHierarchyTranslator.assessmentsAnchor, sourceLanguage: .swift) renderHierarchyTutorial.landmarks.append(RenderHierarchyLandmark(reference: RenderReferenceIdentifier(assessmentReference.absoluteString), kind: .assessment)) let urlGenerator = PresentationURLGenerator(context: context, baseURL: bundle.baseURL) diff --git a/Sources/SwiftDocC/Model/Rendering/RenderContext.swift b/Sources/SwiftDocC/Model/Rendering/RenderContext.swift index 3dd3326f3..76c8b2802 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderContext.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderContext.swift @@ -81,10 +81,10 @@ public struct RenderContext { let assets = documentationContext.assetManagers .reduce(into: [AssetReference: DataAsset]()) { (storage, element) in - let (bundleIdentifier, assetManager) = element + let (bundleID, assetManager) = element for (name, asset) in assetManager.storage { - storage[AssetReference(assetName: name, bundleIdentifier: bundleIdentifier)] = asset + storage[AssetReference(assetName: name, bundleIdentifier: bundleID.rawValue)] = asset } } diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index f377ccb83..52f2e22b3 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -1717,7 +1717,7 @@ public struct RenderNodeTranslator: SemanticVisitor { } let media = ResourceReference(bundleIdentifier: oldMedia.bundleIdentifier, path: mediaIdentifier) - guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleIdentifier: identifier.bundleIdentifier) + guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleIdentifier: identifier.id.rawValue) ?? context.resolveAsset(named: media.path, in: identifier) else { return nil diff --git a/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift b/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift index f1e7f4417..5fccd4bf3 100644 --- a/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift +++ b/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift @@ -300,7 +300,7 @@ extension Folder { } private func makeMinimalTestRenderNode(path: String) -> RenderNode { - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.test", path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.test", path: path, sourceLanguage: .swift) let rawReference = reference.url.absoluteString let title = path.components(separatedBy: "/").last ?? path diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift index 48559ff79..c0790ff0e 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift @@ -103,7 +103,7 @@ struct MergeAction: AsyncAction { let languages = combinedIndex.interfaceLanguages.keys.map { SourceLanguage(id: $0) } let language = languages.sorted().first ?? .swift - let reference = ResolvedTopicReference(bundleIdentifier: landingPageName.replacingWhitespaceAndPunctuation(with: "-"), path: "/documentation", sourceLanguage: language) + let reference = ResolvedTopicReference(id: .init(rawValue: landingPageName), path: "/documentation", sourceLanguage: language) let rootRenderReferences = try readRootNodeRenderReferencesIn(dataDirectory: targetURL.appendingPathComponent("data", isDirectory: true)) diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index 24fa5a638..d0ce1523c 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -20,7 +20,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { /// A resolver returning mock symbols. class TestSymbolResolver: GlobalExternalSymbolResolver { func symbolReferenceAndEntity(withPreciseIdentifier preciseIdentifier: String) -> (ResolvedTopicReference, LinkResolver.ExternalEntity)? { - let reference = ResolvedTopicReference(bundleIdentifier: "com.test.symbols", path: "/\(preciseIdentifier)", sourceLanguage: SourceLanguage.swift) + let reference = ResolvedTopicReference(id: "com.test.symbols", path: "/\(preciseIdentifier)", sourceLanguage: SourceLanguage.swift) let entity = LinkResolver.ExternalEntity( topicRenderReference: TopicRenderReference( identifier: .init(preciseIdentifier), @@ -55,7 +55,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -64,8 +64,8 @@ class ExternalTopicsGraphHashTests: XCTestCase { ## Topics ### External references - - - - + - + - """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } @@ -93,7 +93,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in try """ # ``SideKit/SideClass`` @@ -102,8 +102,8 @@ class ExternalTopicsGraphHashTests: XCTestCase { ## Topics ### External references - - - - + - + - """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } @@ -131,7 +131,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { let externalResolver = self.externalResolver // Load a bundle with external links - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -140,8 +140,8 @@ class ExternalTopicsGraphHashTests: XCTestCase { ## Topics ### External references - - - - + - + - """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } diff --git a/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift index 250dd5b73..453e97849 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -50,7 +50,7 @@ class TopicAnchorHashTests: XCTestCase { } // Add a new section to verify that the hash will change - let newReference = ResolvedTopicReference(bundleIdentifier: "com.bundle.id", path: "/documentation/new#section", sourceLanguage: .swift) + let newReference = ResolvedTopicReference(id: "com.bundle.id", path: "/documentation/new#section", sourceLanguage: .swift) context.nodeAnchorSections[newReference] = AnchorSection(reference: newReference, title: "New Sub-section") // Now verify that the topic anchor hash changed after the change diff --git a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift index 02dc299f1..878bcc512 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift @@ -51,7 +51,7 @@ class TopicGraphHashTests: XCTestCase { } // Here we'll add a completely new node and curated it in the topic graph - let newNode = TopicGraph.Node(reference: .init(bundleIdentifier: #function, path: "/newSymbol", sourceLanguage: .swift), kind: .article, source: .external, title: "External Article") + let newNode = TopicGraph.Node(reference: .init(id: #function, path: "/newSymbol", sourceLanguage: .swift), kind: .article, source: .external, title: "External Article") context.topicGraph.addNode(newNode) // We can force unwrap below because we're guaranteed to find at least one node which is not `newNode` context.topicGraph.addEdge(from: context.topicGraph.nodes.values.first(where: { existingNode -> Bool in @@ -105,7 +105,7 @@ class TopicGraphHashTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -117,7 +117,7 @@ class TopicGraphHashTests: XCTestCase { ]) // Verify correct hierarchy under `MyKit` in the topic graph dump including external symbols. - let myKitRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let myKitRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let myKitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(myKitRef)) let expectedHierarchyWithExternalSymbols = """ diff --git a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift index f30552aaa..d6e423ba5 100644 --- a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift +++ b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -15,7 +15,7 @@ import Markdown class RenderNodeCodableTests: XCTestCase { var bareRenderNode = RenderNode( - identifier: .init(bundleIdentifier: "com.bundle", path: "/", sourceLanguage: .swift), + identifier: .init(id: "com.bundle", path: "/", sourceLanguage: .swift), kind: .article ) @@ -189,7 +189,7 @@ class RenderNodeCodableTests: XCTestCase { ) let reference = ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/documentation/test/customTopicSectionStyle", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift b/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift index 4707f3dbd..2b4154b82 100644 --- a/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift +++ b/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -77,7 +77,7 @@ class RenderNodeVariantOverridesApplierTests: XCTestCase { renderNode.addVariantOverride( pointerComponents: ["identifier"], value: ResolvedTopicReference( - bundleIdentifier: "new-bundle-identifier", + id: "new-bundle-identifier", path: "/path", fragment: nil, sourceLanguage: .objectiveC @@ -193,7 +193,7 @@ class RenderNodeVariantOverridesApplierTests: XCTestCase { ) throws { var renderNode = RenderNode( identifier: ResolvedTopicReference( - bundleIdentifier: "bundle-identifier", + id: "bundle-identifier", path: "", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift index e84bb3213..fea4c4efc 100644 --- a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift +++ b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -14,7 +14,7 @@ import XCTest class TopicRenderReferenceEncoderTests: XCTestCase { func testRenderNodeSkipsReferences() throws { - var node = RenderNode(identifier: .init(bundleIdentifier: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) node.references = [ "reference1": TopicRenderReference(identifier: .init("reference1"), title: "myFunction", abstract: [], url: "/documentation/MyClass/myFunction", kind: .symbol, estimatedTime: nil), ] @@ -51,7 +51,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { func testTopicReferenceEncoder() throws { // Create a render node - var node = RenderNode(identifier: .init(bundleIdentifier: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) node.references = [ "reference1": TopicRenderReference(identifier: .init("reference1"), title: "myFunction", abstract: [], url: "/documentation/MyClass/myFunction", kind: .symbol, estimatedTime: nil), ] @@ -124,7 +124,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { // Create many render nodes. let nodes = (0..<1000) .map({ i -> RenderNode in - var node = RenderNode(identifier: .init(bundleIdentifier: "bundle", path: "/documentation/MyClass\(i)", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass\(i)", sourceLanguage: .swift), kind: .article) node.references = references return node }) diff --git a/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift b/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift index 1d2081dd7..9201ca947 100644 --- a/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift +++ b/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -84,7 +84,7 @@ class DiagnosticTests: XCTestCase { let content = "Test a ``Reference`` in a sentence." let markup = Document(parsing: content, source: URL(string: "/tmp/foo.symbols.json"), options: .parseSymbolLinks) - var resolver = ReferenceResolver(context: context, bundle: bundle, rootReference: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + var resolver = ReferenceResolver(context: context, bundle: bundle, rootReference: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) // Resolve references _ = resolver.visitMarkup(markup) diff --git a/Tests/SwiftDocCTests/Indexing/IndexingTests.swift b/Tests/SwiftDocCTests/Indexing/IndexingTests.swift index bc8ad624f..454fff4c9 100644 --- a/Tests/SwiftDocCTests/Indexing/IndexingTests.swift +++ b/Tests/SwiftDocCTests/Indexing/IndexingTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -16,7 +16,7 @@ class IndexingTests: XCTestCase { // MARK: - Tutorial func testTutorial() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let tutorialReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) let node = try context.entity(with: tutorialReference) let tutorial = node.semantic as! Tutorial var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: tutorialReference) @@ -69,7 +69,7 @@ class IndexingTests: XCTestCase { .init(title: "Section 1", contentSection: [.contentAndMedia(content: contentSection)], stepsSection: [.paragraph(.init(inlineContent: [.text("This is a step.")]))], anchor: "section-1"), .init(title: "Section 2", contentSection: [.contentAndMedia(content: contentSection)], stepsSection: [.paragraph(.init(inlineContent: [.text("This is a step.")]))], anchor: "section-2"), ]) - let tutorialReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/TestTutorial", sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/TestTutorial", sourceLanguage: .swift) let indexingRecords = try tutorialSectionsSection.indexingRecords(onPage: tutorialReference, references: [:]) XCTAssertEqual(2, indexingRecords.count) @@ -90,7 +90,7 @@ class IndexingTests: XCTestCase { func testArticle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let articleReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! TutorialArticle var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) @@ -188,7 +188,7 @@ class IndexingTests: XCTestCase { func testRootPageIndexingRecord() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let articleReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! Symbol var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) @@ -221,7 +221,7 @@ class IndexingTests: XCTestCase { try updatedPlistData.write(to: plistURL) } - let articleReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! Symbol var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 55e992110..483c3d3d1 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -1174,7 +1174,7 @@ Root let imageReference = try XCTUnwrap(renderIndex.references["plus.svg"]) XCTAssertEqual(imageReference.asset.variants.values.map(\.path).sorted(), [ - "/images/\(bundle.identifier)/plus.svg", + "/images/\(bundle.id)/plus.svg", ]) } @@ -1816,7 +1816,7 @@ Root func testNormalizedNavigatorIndexIdentifier() throws { let topicReference = ResolvedTopicReference( - bundleIdentifier: "org.swift.example", + id: "org.swift.example", path: "/documentation/path/sub-path", fragment: nil, sourceLanguage: .swift @@ -1833,7 +1833,7 @@ Root ) let topicReferenceWithCapitalization = ResolvedTopicReference( - bundleIdentifier: "org.Swift.Example", + id: "org.Swift.Example", path: "/documentation/Path/subPath", fragment: nil, sourceLanguage: .swift @@ -1850,7 +1850,7 @@ Root ) let topicReferenceWithFragment = ResolvedTopicReference( - bundleIdentifier: "org.Swift.Example", + id: "org.Swift.Example", path: "/documentation/Path/subPath", fragment: "FRAGMENT", sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift index 507b77c6b..0d64a38cd 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -21,15 +21,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -79,15 +79,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -137,15 +137,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the article page - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion diff --git a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift index 2c689b381..c6a494801 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift @@ -66,7 +66,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -113,7 +113,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -156,7 +156,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift index da312e7da..312f4f0b5 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift @@ -98,7 +98,7 @@ class AutomaticCurationTests: XCTestCase { file: StaticString = #file, line: UInt = #line ) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = try XCTUnwrap(translator.visit(node.semantic) as? RenderNode, file: file, line: line) @@ -130,7 +130,7 @@ class AutomaticCurationTests: XCTestCase { try sideKit.write(to: url.appendingPathComponent("documentation").appendingPathComponent("sidekit.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile the render node to flex the automatic curator let symbol = node.semantic as! Symbol @@ -180,7 +180,7 @@ class AutomaticCurationTests: XCTestCase { """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -342,7 +342,7 @@ class AutomaticCurationTests: XCTestCase { // The first topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -358,7 +358,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -371,7 +371,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -383,21 +383,21 @@ class AutomaticCurationTests: XCTestCase { // The automatically curated symbols shouldn't have a See Also section do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -424,7 +424,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the framework render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -437,7 +437,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the `A` render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/A", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/A", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -477,7 +477,7 @@ class AutomaticCurationTests: XCTestCase { // Load the "MixedLanguageProtocol Implementations" API COllection let protocolImplementationsNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MixedLanguageFramework/MixedLanguageClassConformingToProtocol/MixedLanguageProtocol-Implementations", sourceLanguages: [.swift, .objectiveC] ) @@ -503,7 +503,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MixedLanguageFramework", sourceLanguages: [.swift, .objectiveC] ) @@ -577,7 +577,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/Whatsit", sourceLanguages: [.objectiveC] ) @@ -603,7 +603,7 @@ class AutomaticCurationTests: XCTestCase { let classDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/Whatsit/Whatsit", sourceLanguages: [.objectiveC] ) @@ -638,7 +638,7 @@ class AutomaticCurationTests: XCTestCase { let containerDocumentationNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/ThirdOrder/SomeStruct", sourceLanguages: [.swift] ) @@ -665,7 +665,7 @@ class AutomaticCurationTests: XCTestCase { let rootDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CxxSymbols", sourceLanguage: .objectiveC ) @@ -755,7 +755,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -809,7 +809,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -866,7 +866,7 @@ class AutomaticCurationTests: XCTestCase { let catalogURL = try exampleDocumentation.write(inside: createTemporaryDirectory()) let (_, bundle, context) = try loadBundle(from: catalogURL) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) diff --git a/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift b/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift index fbbba06ed..c866d0131 100644 --- a/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift @@ -139,7 +139,7 @@ class BundleDiscoveryTests: XCTestCase { func checkExpectedFilesFoundIn(_ folder: File, file: StaticString = #file, line: UInt = #line) throws { let bundle = try parsedBundle(from: folder) - XCTAssertEqual(bundle.identifier, expectedBundle.identifier) + XCTAssertEqual(bundle.id, expectedBundle.id) XCTAssertEqual(bundle.displayName, expectedBundle.displayName) func assertEqualFiles(_ got: [URL], _ expected: [URL], file: StaticString = #file, line: UInt = #line) { @@ -233,7 +233,7 @@ class BundleDiscoveryTests: XCTestCase { let (bundle, _) = try inputProvider.inputsAndDataProvider(startingPoint: URL(fileURLWithPath: "/"), options: bundleDiscoveryOptions) // The bundle information was overridden from the options - XCTAssertEqual(bundle.identifier, "org.swift.docc.example") + XCTAssertEqual(bundle.id, "org.swift.docc.example") XCTAssertEqual(bundle.displayName, "Test Bundle") // The fallback should not override this value // The additional symbol graph files are part of the bundle @@ -265,7 +265,7 @@ class BundleDiscoveryTests: XCTestCase { let (bundle, _) = try inputProvider.inputsAndDataProvider(startingPoint: URL(fileURLWithPath: "/\(catalog.name)"), options: bundleDiscoveryOptions) // The bundle information was specified via the options - XCTAssertEqual(bundle.identifier, "com.fallback.bundle.identifier") + XCTAssertEqual(bundle.id, "com.fallback.bundle.identifier") XCTAssertEqual(bundle.displayName, "Fallback Display Name") } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift index adc775d0d..c4440251a 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2022 Apple Inc. and the Swift project authors + Copyright (c) 2022-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -31,7 +31,7 @@ class DocumentationContext_MixedLanguageLinkResolutionTests: XCTestCase { let resolutionResult = context.resolve( .unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(symbolPath: symbolPath))), in: ResolvedTopicReference( - bundleIdentifier: "org.swift.MixedLanguageFramework", + id: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/\(parentPath)", sourceLanguage: .swift ), diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift index 79bd6e314..32cbada06 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift @@ -46,7 +46,7 @@ class DocumentationContext_RootPageTests: XCTestCase { XCTAssertEqual(context.rootModules.map({ $0.url.path }), ["/documentation/ReleaseNotes"]) // Verify the root was crawled - XCTAssertEqual(context.topicGraph.edges[ResolvedTopicReference(bundleIdentifier: "com.test.example", path: "/documentation/ReleaseNotes", sourceLanguage: .swift)]?.map({ $0.url.path }), + XCTAssertEqual(context.topicGraph.edges[ResolvedTopicReference(id: "com.test.example", path: "/documentation/ReleaseNotes", sourceLanguage: .swift)]?.map({ $0.url.path }), ["/documentation/TestBundle/ReleaseNotes-1.2"]) } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 4aa275a32..2703d38e5 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -85,11 +85,11 @@ class DocumentationContextTests: XCTestCase { func testLoadEntity() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let identifier = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "some.other.bundle", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "some.other.bundle", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift))) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/Test-Bundle/wrongIdentifier", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/Test-Bundle/wrongIdentifier", sourceLanguage: .swift))) let node = try context.entity(with: identifier) @@ -423,7 +423,7 @@ class DocumentationContextTests: XCTestCase { func testThrowsErrorForQualifiedImagePaths() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let id = bundle.identifier + let id = bundle.id.rawValue let figure = ResourceReference(bundleIdentifier: id, path: "figure1.jpg") let imageFigure = ResourceReference(bundleIdentifier: id, path: "images/figure1.jpg") @@ -517,7 +517,7 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let imagesRegistered = context - .registeredImageAssets(forBundleID: bundle.identifier) + .registeredImageAssets(forBundleID: bundle.id.rawValue) .flatMap { $0.variants.map { $0.value.lastPathComponent } } .sorted() @@ -561,12 +561,12 @@ class DocumentationContextTests: XCTestCase { func testDownloadAssets() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let downloadsBefore = context.registeredDownloadsAssets(forBundleID: bundle.identifier) + let downloadsBefore = context.registeredDownloadsAssets(forBundleID: bundle.id.rawValue) XCTAssertEqual(downloadsBefore.count, 1) XCTAssertEqual(downloadsBefore.first?.variants.values.first?.lastPathComponent, "project.zip") guard var assetOriginal = context - .registeredImageAssets(forBundleID: bundle.identifier) + .registeredImageAssets(forBundleID: bundle.id.rawValue) .first(where: { asset -> Bool in return asset.variants.values.first(where: { url -> Bool in return url.path.contains("intro.png") @@ -581,7 +581,7 @@ class DocumentationContextTests: XCTestCase { context.updateAsset(named: "intro.png", asset: assetOriginal, in: bundle.rootReference) guard let assetUpdated = context - .registeredImageAssets(forBundleID: bundle.identifier) + .registeredImageAssets(forBundleID: bundle.id.rawValue) .first(where: { asset -> Bool in return asset.variants.values.first(where: { url -> Bool in return url.path.contains("intro.png") @@ -595,7 +595,7 @@ class DocumentationContextTests: XCTestCase { XCTAssertEqual(assetUpdated.context, .download) // Verify the asset is accessible in the downloads collection. - var downloadsAfter = context.registeredDownloadsAssets(forBundleID: bundle.identifier) + var downloadsAfter = context.registeredDownloadsAssets(forBundleID: bundle.id.rawValue) XCTAssertEqual(downloadsAfter.count, 2) downloadsAfter.removeAll(where: { $0.variants.values.first?.lastPathComponent == "project.zip" }) XCTAssertEqual(downloadsAfter.count, 1) @@ -1235,7 +1235,7 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try loadBundle(catalog: testCatalog) let renderContext = RenderContext(documentationContext: context, bundle: bundle) - let identifier = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) let node = try context.entity(with: identifier) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -1326,15 +1326,15 @@ let expected = """ assertEqualDumps(context.dumpGraph(), expected) // Test correct symbol hierarchy in context - XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, + XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, [["doc://org.swift.docc.example/documentation/MyKit"], ["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyProtocol"]]) - XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-33vaw", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, + XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-33vaw", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, [["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyClass"], ["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyProtocol", "doc://org.swift.docc.example/documentation/MyKit/MyClass"]]) } func createNode(in context: DocumentationContext, bundle: DocumentationBundle, parent: ResolvedTopicReference, name: String) throws -> (DocumentationNode, TopicGraph.Node) { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) let node = DocumentationNode(reference: reference, kind: .article, sourceLanguage: .swift, name: .conceptual(title: name), markup: Document(parsing: "# \(name)"), semantic: nil) let tgNode = TopicGraph.Node(reference: reference, kind: .article, source: .external, title: name) @@ -1349,7 +1349,7 @@ let expected = """ func testSortingBreadcrumbsOfEqualDistanceToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) /// /// Create nodes in alphabetical order @@ -1383,7 +1383,7 @@ let expected = """ func testSortingBreadcrumbsOfDifferentDistancesToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let tgMykitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(mykit)) /// @@ -1431,7 +1431,7 @@ let expected = """ }) // Verify the node is a child of the module node when the graph is loaded. - let sideClassReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let sideClassReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) let parents = context.parents(of: sideClassReference) XCTAssertEqual(parents.map {$0.path}, ["/documentation/SideKit"]) } @@ -1452,7 +1452,7 @@ let expected = """ } // Get a node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) // Get the breadcrumbs as paths let paths = context.finitePaths(to: node.reference).sorted { (path1, path2) -> Bool in @@ -1513,8 +1513,8 @@ let expected = """ } // Verify the non-overload collisions were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.enum.case", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.var", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.enum.case", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.var", sourceLanguage: .swift))) } func testModuleLanguageFallsBackToSwiftIfItHasNoSymbols() throws { @@ -1642,9 +1642,9 @@ let expected = """ } // Verify the non-overload collisions were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/tEst-9053a", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-959hd", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/tEst-9053a", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-959hd", sourceLanguage: .swift))) } func testUnknownSymbolKind() throws { @@ -1656,7 +1656,7 @@ let expected = """ } // Get a function node, verify its kind is unknown - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) XCTAssertEqual(node.kind, .unknown) } @@ -1840,7 +1840,7 @@ let expected = """ let problems = context.problems XCTAssertEqual(problems.count, 0, "Unexpected problems: \(problems.map(\.diagnostic.summary).sorted())") - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let entity = try context.entity(with: moduleReference) let moduleSymbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -2023,9 +2023,9 @@ let expected = """ XCTAssert(symbolGraphProblems.isEmpty, "There shouldn't be any errors or warnings in the symbol graphs") // Verify the non-overload collisions form different symbol graph files were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class/path", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/sideClass-swift.var", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/sideClass-swift.var", sourceLanguage: .swift))) } func testUnresolvedSidecarDiagnostics() throws { @@ -2097,7 +2097,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) let node = try context.entity(with: reference) XCTAssertEqual((node.semantic as? Symbol)?.abstract?.plainText, "Extend a symbol with a space in its name.") @@ -2147,7 +2147,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -2156,7 +2156,7 @@ let expected = """ } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -2312,17 +2312,17 @@ let expected = """ } // Test that collision symbol reference was updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) // Test that collision symbol child reference was updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/path", sourceLanguage: .swift))) // Test that nested collisions were updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property", sourceLanguage: .swift))) // Test that child of nested collision is updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum/path", sourceLanguage: .swift))) // Verify that the symbol index has been updated with the rewritten collision-corrected symbol paths XCTAssertEqual(context.documentationCache.reference(symbolID: "s:7SideKit0A5ClassC10testnEE")?.path, "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property") @@ -2445,14 +2445,14 @@ let expected = """ } // Verify that the Tertiary framework has no symbol in the graph - XCTAssertNotNil(try? context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))) - XCTAssertNil(try? context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Tertiary", sourceLanguage: .swift))) + XCTAssertNotNil(try? context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))) + XCTAssertNil(try? context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Tertiary", sourceLanguage: .swift))) } func testDeclarationTokenKinds() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFunc = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let myFunc = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) // Symbol graph declaration tokens, including more esoteric kinds like internalParam, externalParam, and unknown kinds. let tokens = (myFunc.symbol!.mixins[SymbolGraph.Symbol.DeclarationFragments.mixinKey] as? SymbolGraph.Symbol.DeclarationFragments)? @@ -2600,7 +2600,7 @@ let expected = """ func testNavigatorTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func renderNodeForPath(path: String) throws -> (DocumentationNode, RenderNode) { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2655,7 +2655,7 @@ let expected = """ let (_, _, context) = try loadBundle(from: catalogURL) let referenceForPath: (String) -> ResolvedTopicReference = { path in - return ResolvedTopicReference(bundleIdentifier: "com.test.collisions", path: "/documentation" + path, sourceLanguage: .swift) + return ResolvedTopicReference(id: "com.test.collisions", path: "/documentation" + path, sourceLanguage: .swift) } // Verify that: @@ -2722,13 +2722,13 @@ let expected = """ let beforeCount = try XCTUnwrap(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Verify a given identifier exists in the pool by creating it and verifying it wasn't added to the pool - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) // Verify create the reference above did not add to the cache XCTAssertEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Create a new reference for the same bundle that was not loaded with the context - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) // Verify creating a new reference added to the ones loaded with the context XCTAssertNotEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) @@ -2742,7 +2742,7 @@ let expected = """ // Get the SideKit/SideClass/init() node and verify it has an abstract and no discussion. // We're verifying that the metadata directive between the title and the abstract didn't cause // the content to overflow into the discussion. - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) let markupModel = DocumentationMarkup(markup: node.markup) XCTAssertNotNil(markupModel.abstractSection) @@ -2772,7 +2772,7 @@ let expected = """ func testCreatingAnArticleNode() throws { // Create documentation node from markup - let reference = ResolvedTopicReference(bundleIdentifier: "com.testbundle", path: "/documentation/NewArticle", fragment: nil, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "com.testbundle", path: "/documentation/NewArticle", fragment: nil, sourceLanguage: .swift) let source = """ # New Article @@ -2791,7 +2791,7 @@ let expected = """ let (bundle, context) = try testBundleAndContext(named: "TestBundle") // Verify task group ranges are persisted for symbol docs - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let symbol = try XCTUnwrap((try? context.entity(with: symbolReference))?.semantic as? Symbol) let symbolTopics = try XCTUnwrap(symbol.topics) symbolTopics.originalLinkRangesByGroup.forEach { group in @@ -2799,7 +2799,7 @@ let expected = """ } // Verify task group ranges are persisted for articles - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let article = try XCTUnwrap((try? context.entity(with: articleReference))?.semantic as? Article) let articleTopics = try XCTUnwrap(article.topics) articleTopics.originalLinkRangesByGroup.forEach { group in @@ -3362,7 +3362,7 @@ let expected = """ "'swiftOnlyMemberName' doesn't exist at '/ModuleName/ObjectiveCName'", ]) - let reference = ResolvedTopicReference(bundleIdentifier: "unit-test", path: "/documentation/ModuleName/SwiftName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "unit-test", path: "/documentation/ModuleName/SwiftName", sourceLanguage: .swift) let entity = try context.entity(with: reference) let symbol = try XCTUnwrap(entity.semantic as? Symbol) let taskGroups = try XCTUnwrap(symbol.topics).taskGroups @@ -3471,10 +3471,10 @@ let expected = """ """.write(to: url.appendingPathComponent("fifthTestMember.md"), atomically: true, encoding: .utf8) } - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) // Fetch the "OverloadedParentStruct" node - let reference1 = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(id: bundle.id, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) let node1 = try context.entity(with: reference1) let symbol1 = try XCTUnwrap(node1.semantic as? Symbol) @@ -3487,7 +3487,7 @@ let expected = """ XCTAssertTrue(tgNode1.contains(articleReference)) // Fetch the "fifthTestMember" node - let reference2 = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) + let reference2 = ResolvedTopicReference(id: bundle.id, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) let node2 = try context.entity(with: reference2) let symbol2 = try XCTUnwrap(node2.semantic as? Symbol) @@ -3570,7 +3570,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3579,7 +3579,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3588,7 +3588,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3597,7 +3597,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3606,7 +3606,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3681,7 +3681,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3690,7 +3690,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3699,7 +3699,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3708,7 +3708,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3742,7 +3742,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3751,7 +3751,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3777,7 +3777,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Something", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Something", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3885,7 +3885,7 @@ let expected = """ let identifiers = context.problems.map(\.diagnostic.identifier) XCTAssertFalse(identifiers.contains(where: { $0 == "org.swift.docc.ArticleUncurated" })) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNil(article.topics) @@ -3922,7 +3922,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNotNil(article.topics) @@ -3965,7 +3965,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) @@ -3993,12 +3993,12 @@ let expected = """ .replacingOccurrences(of: " - ", with: " - ") .write(to: myKitURL, atomically: true, encoding: .utf8) } - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) // Try resolving the new resolvable node switch context.resolve(.unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc:resolvable-article")!)), in: moduleReference) { case .success(let resolvedReference): - XCTAssertEqual(resolvedReference.absoluteString, "doc://\(bundle.identifier)/documentation/Test-Bundle/resolvable-article") + XCTAssertEqual(resolvedReference.absoluteString, "doc://\(bundle.id)/documentation/Test-Bundle/resolvable-article") XCTAssertNoThrow(try context.entity(with: resolvedReference)) case .failure(_, let errorMessage): XCTFail("Did not resolve resolvable link. Error: \(errorMessage)") @@ -4147,12 +4147,12 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Resolve from various locations in the bundle for parent in [bundle.rootReference, bundle.documentationRootReference, bundle.tutorialTableOfContentsContainer] { @@ -4184,14 +4184,14 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) let symbolReference = try XCTUnwrap(context.documentationCache.reference(symbolID: "s:12Minimal_docs4TestV")) @@ -4244,9 +4244,9 @@ let expected = """ // Load the bundle let (_, bundle, context) = try loadBundle(from: tempFolderURL) - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) - let articleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Verify we resolve/not resolve non-symbols when calling directly context.resolve(...) // with an explicit preference. @@ -4272,7 +4272,7 @@ let expected = """ // Verify the context contains the conflicting topic names // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol XCTAssertNotNil(context.documentationCache[symbolReference]) @@ -4315,8 +4315,8 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the module and symbol node kinds. - let symbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) XCTAssertEqual(context.topicGraph.nodeWithReference(symbolReference)?.kind, .structure) XCTAssertEqual(context.topicGraph.nodeWithReference(moduleReference)?.kind, .module) @@ -4443,7 +4443,7 @@ let expected = """ XCTAssertEqual( context.documentationExtensionURL( for: ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift @@ -4461,7 +4461,7 @@ let expected = """ XCTAssertNil( context.documentationExtensionURL( for: ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/tutorials/TestOverview", fragment: nil, sourceLanguage: .swift @@ -4686,7 +4686,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) XCTAssertEqual( context.topicGraph.reverseEdgesGraph.cycles(from: reference).map { $0.map(\.lastPathComponent) }, @@ -4771,7 +4771,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { var seenIndices = Set() @@ -4859,7 +4859,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { switch context.resolve(.unresolved(.init(topicURL: .init(symbolPath: "SymbolName-\(kindID.identifier)"))), in: moduleReference, fromSymbolLink: true) { @@ -4991,7 +4991,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5068,7 +5068,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5143,7 +5143,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5213,7 +5213,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5285,7 +5285,7 @@ let expected = """ return entity.externallyLinkableElementSummaries(context: context, renderNode: renderNode, includeTaskGroups: false) } - let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.identifier) + let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) return (linkResolutionInformation, linkSummaries) } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift index 9f48acd1d..52b8d6788 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -31,7 +31,7 @@ class DocumentationCuratorTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") var crawler = DocumentationCurator.init(in: context, bundle: bundle) - let mykit = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + let mykit = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) var symbolsWithCustomCuration = [ResolvedTopicReference]() var curatedRelationships = [ParentChild]() @@ -98,7 +98,7 @@ class DocumentationCuratorTests: XCTestCase { let extensionFile = tempCatalogURL.appendingPathComponent("documentation/myfunction.md") var crawler = DocumentationCurator(in: context, bundle: bundle) - let mykit = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + let mykit = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) XCTAssertNoThrow(try crawler.crawlChildren(of: mykit.reference, prepareForCuration: { _ in }, relateNodes: { _, _ in })) @@ -285,7 +285,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in module parent do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -293,7 +293,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in self do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -301,7 +301,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in a child do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -309,7 +309,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve child in its parent do { let symbolLink = SymbolLink(destination: "myFunction()") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass/myFunction()") } @@ -317,7 +317,7 @@ class DocumentationCuratorTests: XCTestCase { // Do not resolve when not found do { let symbolLink = SymbolLink(destination: "myFunction") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, nil) } @@ -325,7 +325,7 @@ class DocumentationCuratorTests: XCTestCase { // Fail to resolve across modules do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) XCTAssertNil(crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent)) } } @@ -338,7 +338,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve and curate an article in module root (absolute link) do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -352,7 +352,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate an article in module root (relative link) do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -366,7 +366,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate article in the module root from within a child symbol do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -380,7 +380,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate absolute link from a different module parent do { let link = Link(destination: "doc:documentation/Test-Bundle/article") - let parent = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) XCTAssertNotNil(crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot)) } } @@ -427,7 +427,7 @@ class DocumentationCuratorTests: XCTestCase { } var crawler = DocumentationCurator.init(in: context, bundle: bundle) - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) try crawler.crawlChildren(of: reference, prepareForCuration: {_ in }) { (_, _) in } @@ -482,7 +482,7 @@ class DocumentationCuratorTests: XCTestCase { func testMixedManualAndAutomaticCuration() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) let entity = try context.entity(with: reference) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -497,14 +497,14 @@ class DocumentationCuratorTests: XCTestCase { // Verify that the ONLY curation for `TopClass/name` is the manual curation under `MyArticle` // and the automatic curation under `TopClass` is not present. - let nameReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) + let nameReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: nameReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], ]) // Verify that the BOTH manual curations for `TopClass/age` are preserved // even if one of the manual curations overlaps with the inheritance edge from the symbol graph. - let ageReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) + let ageReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: ageReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass"], ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], @@ -516,7 +516,7 @@ class DocumentationCuratorTests: XCTestCase { func testMultipleManualCurationIsPreserved() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: reference).map({ $0.map({ $0.path }) }), [ [ diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift index 44ab50964..a2d9db632 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift @@ -715,7 +715,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { return entity.externallyLinkableElementSummaries(context: dependencyContext, renderNode: renderNode, includeTaskGroups: false) } - let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.identifier) + let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.id.rawValue) XCTAssertEqual(linkResolutionInformation.pathHierarchy.nodes.count - linkResolutionInformation.nonSymbolPaths.count, 5 /* 4 symbols & 1 module */) XCTAssertEqual(linkSummaries.count, 5 /* 4 symbols & 1 module */) @@ -798,7 +798,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { // Check the relationships of 'SomeClass' do { - let reference = ResolvedTopicReference(bundleIdentifier: mainBundle.identifier, path: "/documentation/Main/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: mainBundle.id, path: "/documentation/Main/SomeClass", sourceLanguage: .swift) let entity = try mainContext.entity(with: reference) let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity)) @@ -822,7 +822,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { // Check the declaration of 'someFunction' do { - let reference = ResolvedTopicReference(bundleIdentifier: mainBundle.identifier, path: "/documentation/Main/SomeClass/someFunction(parameter:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: mainBundle.id, path: "/documentation/Main/SomeClass/someFunction(parameter:)", sourceLanguage: .swift) let entity = try mainContext.entity(with: reference) let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity)) @@ -989,13 +989,13 @@ class ExternalPathHierarchyResolverTests: XCTestCase { } } - private func makeLinkResolversForTestBundle(named testBundleName: String, configuration: DocumentationContext.Configuration = .init()) throws -> LinkResolvers { + private func makeLinkResolversForTestBundle(named testBundleName: String, configuration: DocumentationContext.Configuration = .init()) throws -> LinkResolvers { let bundleURL = try XCTUnwrap(Bundle.module.url(forResource: testBundleName, withExtension: "docc", subdirectory: "Test Bundles")) let (_, bundle, context) = try loadBundle(from: bundleURL, configuration: configuration) let localResolver = try XCTUnwrap(context.linkResolver.localResolver) - let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.identifier) + let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) let resolverData = try JSONEncoder().encode(resolverInfo) let roundtripResolverInfo = try JSONDecoder().decode(SerializableLinkResolutionInformation.self, from: resolverData) diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 1c1223938..0efce7d5f 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -16,7 +16,7 @@ import SwiftDocCTestUtilities class ExternalReferenceResolverTests: XCTestCase { class TestExternalReferenceResolver: ExternalDocumentationSource { - var bundleIdentifier = "com.external.testbundle" + var bundleID: DocumentationBundle.Identifier = "com.external.testbundle" var expectedReferencePath = "/externally/resolved/path" var expectedFragment: String? = nil var resolvedEntityTitle = "Externally Resolved Title" @@ -30,11 +30,11 @@ class ExternalReferenceResolverTests: XCTestCase { if let path = reference.url?.path { resolvedExternalPaths.append(path) } - return .success(ResolvedTopicReference(bundleIdentifier: bundleIdentifier, path: expectedReferencePath, fragment: expectedFragment, sourceLanguage: resolvedEntityLanguage)) + return .success(ResolvedTopicReference(id: bundleID, path: expectedReferencePath, fragment: expectedFragment, sourceLanguage: resolvedEntityLanguage)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { - guard reference.bundleIdentifier == bundleIdentifier else { + guard reference.id == bundleID else { fatalError("It is a programming mistake to retrieve an entity for a reference that the external resolver didn't resolve.") } @@ -69,14 +69,14 @@ class ExternalReferenceResolverTests: XCTestCase { } let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://com.external.testbundle/article")!) - let parent = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyClass", sourceLanguage: .swift) guard case let .success(resolved) = context.resolve(.unresolved(unresolved), in: parent) else { XCTFail("Couldn't resolve \(unresolved)") return } - XCTAssertEqual("com.external.testbundle", resolved.bundleIdentifier) + XCTAssertEqual("com.external.testbundle", resolved.id) XCTAssertEqual("/externally/resolved/path", resolved.path) let expectedURL = URL(string: "doc://com.external.testbundle/externally/resolved/path") @@ -88,7 +88,7 @@ class ExternalReferenceResolverTests: XCTestCase { // manually curate it. (94406023) func testExternalReferenceInOtherLanguageIsIncludedInTopicGroup() throws { let externalResolver = TestExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.expectedReferencePath = "/path/to/external/api" externalResolver.resolvedEntityTitle = "Name of API" externalResolver.resolvedEntityKind = .tutorialTableOfContents @@ -98,7 +98,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext( copying: "TestBundle", - externalResolvers: [externalResolver.bundleIdentifier: externalResolver] + externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] ) { url in let sideClassExtension = """ # ``SideKit/SideClass`` @@ -120,7 +120,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) let sideClassReference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift ) @@ -179,10 +179,10 @@ class ExternalReferenceResolverTests: XCTestCase { do { class TestFallbackResolver: ConvertServiceFallbackResolver { init(bundleIdentifier: String) { - resolver.bundleIdentifier = bundleIdentifier + resolver.bundleID = DocumentationBundle.Identifier(rawValue: bundleIdentifier) } var bundleIdentifier: String { - resolver.bundleIdentifier + resolver.bundleID.rawValue } private var resolver = TestExternalReferenceResolver() func resolve(_ reference: SwiftDocC.TopicReference) -> TopicReferenceResolutionResult { @@ -221,9 +221,9 @@ class ExternalReferenceResolverTests: XCTestCase { func testLoadEntityForExternalReference() throws { let (_, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: ["com.external.testbundle" : TestExternalReferenceResolver()]) - let identifier = ResolvedTopicReference(bundleIdentifier: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: "some.other.bundle", path: identifier.path, sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "some.other.bundle", path: identifier.path, sourceLanguage: .swift))) XCTAssertThrowsError(try context.entity(with: identifier)) } @@ -246,22 +246,22 @@ class ExternalReferenceResolverTests: XCTestCase { let (resolvedEntityKind, renderNodeKind) = fixture let externalResolver = TestExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.expectedReferencePath = "/path/to/external/symbol" externalResolver.resolvedEntityTitle = "ClassName" externalResolver.resolvedEntityKind = resolvedEntityKind - let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) + let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let fileURL = context.documentURL(for: node.reference) else { XCTFail("Unable to find the file for \(node.reference.path)") return } - let expectedReference = "doc://\(externalResolver.bundleIdentifier)\(externalResolver.expectedReferencePath)" + let expectedReference = "doc://\(externalResolver.bundleID)\(externalResolver.expectedReferencePath)" XCTAssertTrue( try String(contentsOf: fileURL).contains("<\(expectedReference)>"), "The test content should include a link for the external reference resolver to resolve" @@ -283,7 +283,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testReferenceFromRenderedPageHasFragments() throws { let externalResolver = TestExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.expectedReferencePath = "/path/to/external/symbol" externalResolver.resolvedEntityTitle = "ClassName" externalResolver.resolvedEntityKind = .class @@ -293,7 +293,7 @@ class ExternalReferenceResolverTests: XCTestCase { .init(kind: .identifier, spelling: "ClassName", preciseIdentifier: nil), ]) - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -308,7 +308,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -330,7 +330,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testExternalReferenceWithDifferentResolvedPath() throws { let externalResolver = TestExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" // Return a different path for this resolved reference externalResolver.expectedReferencePath = "/path/to/externally-resolved-symbol" externalResolver.resolvedEntityTitle = "ClassName" @@ -349,11 +349,11 @@ class ExternalReferenceResolverTests: XCTestCase { ]) var configuration = DocumentationContext.Configuration() - configuration.externalDocumentationConfiguration.sources = [externalResolver.bundleIdentifier: externalResolver] + configuration.externalDocumentationConfiguration.sources = [externalResolver.bundleID.rawValue: externalResolver] let (bundle, context) = try loadBundle(catalog: tempFolder, configuration: configuration) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/article", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -380,12 +380,12 @@ class ExternalReferenceResolverTests: XCTestCase { func testSampleCodeReferenceHasSampleCodeRole() throws { let externalResolver = TestExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.expectedReferencePath = "/path/to/external/sample" externalResolver.resolvedEntityTitle = "Name of Sample" externalResolver.resolvedEntityKind = .sampleCode - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -400,7 +400,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -419,7 +419,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testExternalTopicWithTopicImage() throws { let externalResolver = TestMultiResultExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.entitiesToReturn["/path/to/external-page-with-topic-image-1"] = .success(.init( referencePath: "/path/to/external-page-with-topic-image-1", @@ -473,7 +473,7 @@ class ExternalReferenceResolverTests: XCTestCase { ), ] - let (_, bundle, context) = try testBundleAndContext(copying: "SampleBundle", excludingPaths: ["MySample.md", "MyLocalSample.md"], externalResolvers: [externalResolver.bundleIdentifier: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "SampleBundle", excludingPaths: ["MySample.md", "MyLocalSample.md"], externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in try """ # SomeSample @@ -499,7 +499,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SomeSample", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SomeSample", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -612,7 +612,7 @@ class ExternalReferenceResolverTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -644,7 +644,7 @@ class ExternalReferenceResolverTests: XCTestCase { }) // Verify the external symbol is included in external cache - let reference = ResolvedTopicReference(bundleIdentifier: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) XCTAssertNil(context.documentationCache[reference]) XCTAssertNotNil(context.externalCache[reference]) @@ -690,7 +690,7 @@ class ExternalReferenceResolverTests: XCTestCase { } } // Note that this resolved reference doesn't have the same path as the unresolved reference. - return .success(.init(bundleIdentifier: "com.external.testbundle", path: "/resolved", sourceLanguage: .swift)) + return .success(.init(id: "com.external.testbundle", path: "/resolved", sourceLanguage: .swift)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { @@ -757,18 +757,18 @@ class ExternalReferenceResolverTests: XCTestCase { // Expected successful externally resolved reference. XCTAssertEqual( context.externallyResolvedLinks[ValidatedURL(parsingExact: "doc://com.external.testbundle/resolvable")!], - TopicReferenceResolutionResult.success(ResolvedTopicReference(bundleIdentifier: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) + TopicReferenceResolutionResult.success(ResolvedTopicReference(id: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) ) XCTAssertEqual( context.externallyResolvedLinks[ValidatedURL(parsingExact: "doc://com.external.testbundle/resolved")!], - TopicReferenceResolutionResult.success(ResolvedTopicReference(bundleIdentifier: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) + TopicReferenceResolutionResult.success(ResolvedTopicReference(id: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) ) XCTAssert(context.problems.contains(where: { $0.diagnostic.summary.contains("Unit test: External resolve error.")}), "The external reference resolver error message is included in that problem's error summary.") // Get MyKit symbol - let entity = try context.entity(with: .init(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let renderNode = try converter.convert(entity) @@ -810,7 +810,7 @@ class ExternalReferenceResolverTests: XCTestCase { .write(to: myClassMDURL, atomically: true, encoding: .utf8) }) - let myClassRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let myClassRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let documentationNode = try context.entity(with: myClassRef) // Verify the external link was resolved in markup. @@ -831,7 +831,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testExternalArticlesAreIncludedInAllVariantsTopicsSection() throws { let externalResolver = TestMultiResultExternalReferenceResolver() - externalResolver.bundleIdentifier = "com.test.external" + externalResolver.bundleID = "com.test.external" externalResolver.entitiesToReturn["/path/to/external/swiftArticle"] = .success( .init( @@ -871,7 +871,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext( copying: "MixedLanguageFramework", - externalResolvers: [externalResolver.bundleIdentifier: externalResolver] + externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] ) { url in let mixedLanguageFrameworkExtension = """ # ``MixedLanguageFramework`` @@ -891,7 +891,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) let mixedLanguageFrameworkReference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MixedLanguageFramework", sourceLanguage: .swift ) @@ -962,12 +962,12 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleIdentifier: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -976,7 +976,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -1018,7 +1018,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleIdentifier: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1037,7 +1037,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/First", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/First", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1051,7 +1051,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Second", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Second", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1085,7 +1085,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleIdentifier: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1170,12 +1170,12 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleIdentifier: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. @@ -1203,7 +1203,7 @@ class ExternalReferenceResolverTests: XCTestCase { let externalResolver = TestExternalReferenceResolver() let (_, bundle, context) = try testBundleAndContext( copying: bundleName, - externalResolvers: [externalResolver.bundleIdentifier: externalResolver] + externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] ) { url in try documentationExtension.utf8Content.write( to: url.appendingPathComponent(documentationExtension.name), @@ -1214,7 +1214,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))", file: file, line: line) // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. diff --git a/Tests/SwiftDocCTests/Infrastructure/Input Discovery/DocumentationInputsProviderTests.swift b/Tests/SwiftDocCTests/Infrastructure/Input Discovery/DocumentationInputsProviderTests.swift index 4864c1dc8..5778863dd 100644 --- a/Tests/SwiftDocCTests/Infrastructure/Input Discovery/DocumentationInputsProviderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/Input Discovery/DocumentationInputsProviderTests.swift @@ -150,7 +150,7 @@ class DocumentationInputsProviderTests: XCTestCase { options: .init() ) XCTAssertEqual(foundInputs.displayName, "two") - XCTAssertEqual(foundInputs.identifier, "two") + XCTAssertEqual(foundInputs.id, "two") } // Without arbitrary directories as a fallback @@ -240,7 +240,7 @@ class DocumentationInputsProviderTests: XCTestCase { ]) ) XCTAssertEqual(foundInputs.displayName, "Something") - XCTAssertEqual(foundInputs.identifier, "Something") + XCTAssertEqual(foundInputs.id, "Something") XCTAssertEqual(foundInputs.symbolGraphURLs.map(\.path), [ "/path/to/Something.symbols.json", ]) diff --git a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift index 007db4a89..a0c675580 100644 --- a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -27,7 +27,7 @@ class NodeTagsTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL) // Verify that `Test` is marked as SPI. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) let node = try XCTUnwrap(context.entity(with: reference)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssertTrue(symbol.isSPI) @@ -39,7 +39,7 @@ class NodeTagsTests: XCTestCase { XCTAssertEqual(renderNode.metadata.tags, [.spi]) // Verify that the link to the node contains the SPI tag. - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) let moduleNode = try XCTUnwrap(context.entity(with: moduleReference)) let moduleSymbol = try XCTUnwrap(moduleNode.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift index a3b3c6aca..adebeb192 100644 --- a/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -50,27 +50,27 @@ class NodeURLGeneratorTests: XCTestCase { let baseURL = URL(string: "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/")! let generator = NodeURLGenerator(baseURL: baseURL) - let basicIdentifier = ResolvedTopicReference(bundleIdentifier: "com.example.testbundle", + let basicIdentifier = ResolvedTopicReference(id: "com.example.testbundle", path: "/folder/class/symbol", fragment: nil, sourceLanguage: .swift) XCTAssertEqual(generator.urlForReference(basicIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/symbol") - let symbolIdentifier = ResolvedTopicReference(bundleIdentifier: "com.example.testbundle", + let symbolIdentifier = ResolvedTopicReference(id: "com.example.testbundle", path: "/folder/class/.==", fragment: nil, sourceLanguage: .swift) XCTAssertEqual(generator.urlForReference(symbolIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/'.==") - let privateIdentifier = ResolvedTopicReference(bundleIdentifier: "com.example.testbundle", + let privateIdentifier = ResolvedTopicReference(id: "com.example.testbundle", path: "/folder/class/_privateMethod", fragment: nil, sourceLanguage: .objectiveC) XCTAssertEqual(generator.urlForReference(privateIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/_privateMethod") XCTAssertEqual(generator.urlForReference(privateIdentifier, lowercased: true).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/_privatemethod") - let classIdentifier = ResolvedTopicReference(bundleIdentifier: "com.example.testbundle", + let classIdentifier = ResolvedTopicReference(id: "com.example.testbundle", path: "/folder/_privateclass/_privatesubclass", fragment: nil, sourceLanguage: .objectiveC) diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index 5f8c25901..52a84ef6d 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -1112,7 +1112,7 @@ class PathHierarchyTests: XCTestCase { let tree = try XCTUnwrap(linkResolver.pathHierarchy) // Test finding the parent via the `fromTopicReference` integration shim. - let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)]! + let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)]! XCTAssertNotNil(parentID) XCTAssertEqual(try tree.findSymbol(path: "globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") XCTAssertEqual(try tree.findSymbol(path: "MyKit/globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") diff --git a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift index 72a0dd7a4..791a897f9 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift @@ -18,19 +18,19 @@ class PresentationURLGeneratorTests: XCTestCase { let generator = PresentationURLGenerator(context: context, baseURL: URL(string: "https://host:1024/webPrefix")!) // Test resolved tutorial reference - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(reference).absoluteString, "https://host:1024/webPrefix/tutorials/test-bundle/testtutorial") // Test resolved symbol reference - let symbol = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let symbol = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(symbol).absoluteString, "https://host:1024/webPrefix/documentation/mykit/myclass") // Test root - let root = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/", sourceLanguage: .swift) + let root = ResolvedTopicReference(id: bundle.id, path: "/", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(root).absoluteString, "https://host:1024/webPrefix/documentation") // Fragment - let fragment = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) + let fragment = ResolvedTopicReference(id: bundle.id, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(fragment).absoluteString, "https://host:1024/webPrefix/path#test-URL-FRAGMENT") } } diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index 3f0bac41d..fca0bb31e 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -100,7 +100,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -126,7 +126,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -152,7 +152,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -178,7 +178,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -203,7 +203,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -229,7 +229,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -377,7 +377,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -409,7 +409,7 @@ class ReferenceResolverTests: XCTestCase { func testCuratedExtensionRemovesEmptyPage() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithSingleExtension") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -421,7 +421,7 @@ class ReferenceResolverTests: XCTestCase { // Make sure that the symbol added in the extension is still present in the topic graph, // even though its synthetic "extended symbol" parents are not - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) } func testCuratedExtensionWithDanglingReference() throws { @@ -445,15 +445,15 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) // Load the RenderNode for the root article and make sure that the `Swift/Array` symbol link // is not rendered as a link - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -485,10 +485,10 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) } @@ -514,17 +514,17 @@ class ReferenceResolverTests: XCTestCase { XCTAssertFalse(context.problems.contains(where: { $0.diagnostic.identifier == "org.swift.docc.removedExtensionLinkDestination" || $0.diagnostic.identifier == "org.swift.docc.unresolvedTopicReference" })) // Because the `Swift/Array` extension has an extension article, the pages should not be marked as virtual - let extendedModule = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedStructure })) } func testCuratedExtensionWithAdditionalConformance() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithConformanceAndExtension") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -540,7 +540,7 @@ class ReferenceResolverTests: XCTestCase { func testExtensionWithEmptyDeclarationFragments() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithEmptyDeclarationFragments") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -738,8 +738,8 @@ class ReferenceResolverTests: XCTestCase { } func testEmitsDiagnosticsForEachDocumentationChunk() throws { - let moduleReference = ResolvedTopicReference(bundleIdentifier: "com.example.test", path: "/documentation/ModuleName", sourceLanguage: .swift) - let reference = ResolvedTopicReference(bundleIdentifier: "com.example.test", path: "/documentation/ModuleName/Something", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: "com.example.test", path: "/documentation/ModuleName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "com.example.test", path: "/documentation/ModuleName/Something", sourceLanguage: .swift) let inSourceComment = """ Some description of this class diff --git a/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift b/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift index 9e7ac1580..f8865b7f8 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -16,7 +16,7 @@ import XCTest class ResolvedTopicReferenceTests: XCTestCase { func testReferenceURL() { let firstTopicReference = ResolvedTopicReference( - bundleIdentifier: "bundleID", + id: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift @@ -24,7 +24,7 @@ class ResolvedTopicReferenceTests: XCTestCase { XCTAssertEqual(firstTopicReference.absoluteString, "doc://bundleID/path/sub-path#fragment") let secondTopicReference = ResolvedTopicReference( - bundleIdentifier: "new-bundleID", + id: "new-bundleID", path: "/new-path/sub-path", fragment: firstTopicReference.fragment, sourceLanguage: firstTopicReference.sourceLanguage @@ -41,7 +41,7 @@ class ResolvedTopicReferenceTests: XCTestCase { func testAppendingReferenceWithEmptyPath() { // An empty path do { - let resolvedOriginal = ResolvedTopicReference(bundleIdentifier: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) + let resolvedOriginal = ResolvedTopicReference(id: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://host-name")!) XCTAssert(unresolved.path.isEmpty) @@ -52,7 +52,7 @@ class ResolvedTopicReferenceTests: XCTestCase { // A path with no url path allowed characters do { - let resolvedOriginal = ResolvedTopicReference(bundleIdentifier: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) + let resolvedOriginal = ResolvedTopicReference(id: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) var components = URLComponents() components.scheme = "doc" @@ -69,7 +69,7 @@ class ResolvedTopicReferenceTests: XCTestCase { func testStorageIsConcurrentlyAccessible() throws { let topicReference = ResolvedTopicReference( - bundleIdentifier: "com.apple.example", + id: "com.apple.example", path: "/documentation/path/sub-path", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index 2d24ec724..a0836bd33 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -24,10 +24,10 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let targetRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/B", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let targetRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/B", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: sourceType, mixins: [:]) let targetSymbol = SymbolGraph.Symbol(identifier: targetIdentifier, names: SymbolGraph.Symbol.Names(title: "B", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "B"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: targetType, mixins: [:]) @@ -130,8 +130,8 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: SymbolGraph.Symbol.Kind(parsedIdentifier: .class, displayName: "Class"), mixins: [:]) diff --git a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift index f1d3aae34..c22480d22 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift @@ -17,7 +17,7 @@ import Markdown // instead to verify a mix of successes and failures in the same test. class TestMultiResultExternalReferenceResolver: ExternalDocumentationSource { - var bundleIdentifier = "com.external.testbundle" + var bundleID: DocumentationBundle.Identifier = "com.external.testbundle" // The minimal information that the test resolver needs to create a resolved reference and documentation node struct EntityInfo { @@ -52,13 +52,13 @@ class TestMultiResultExternalReferenceResolver: ExternalDocumentationSource { let entity = entityInfo(path: path) return .success( - ResolvedTopicReference(bundleIdentifier: bundleIdentifier,path: entity.referencePath,fragment: entity.fragment,sourceLanguage: entity.language) + ResolvedTopicReference(id: bundleID, path: entity.referencePath,fragment: entity.fragment,sourceLanguage: entity.language) ) } } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { - guard reference.bundleIdentifier == bundleIdentifier else { + guard reference.id == bundleID else { fatalError("It is a programming mistake to retrieve an entity for a reference that the external resolver didn't resolve.") } return makeNode(for: entityInfo(path: reference.path), reference: reference) diff --git a/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift b/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift index d109198a4..13f51ad2a 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift @@ -16,7 +16,7 @@ class TopicGraphTests: XCTestCase { /// Returns a ``ResolvedTopicReference`` with the given title, with a phony source language, kind, and source. These are not for testing specific relationships, only abstract graph connectivity. static func testNodeWithTitle(_ title: String) -> TopicGraph.Node { let urlSafeTitle = title.replacingOccurrences(of: " ", with: "_") - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TopicGraphTests", path: "/\(urlSafeTitle)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(urlSafeTitle)", sourceLanguage: .swift) return TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: URL(fileURLWithPath: "/path/to/\(urlSafeTitle)")), title: title) } diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 05d3db508..03bc09d5c 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -98,7 +98,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) @@ -154,7 +154,7 @@ class ExternalLinkableTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -198,7 +198,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -239,7 +239,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -274,7 +274,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -331,7 +331,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) var summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -415,16 +415,16 @@ class ExternalLinkableTests: XCTestCase { summary.references = summary.references?.compactMap { (original: RenderReference) -> RenderReference? in guard var imageRef = original as? ImageReference else { return nil } imageRef.asset.variants = imageRef.asset.variants.mapValues { variant in - return imageRef.destinationURL(for: variant.lastPathComponent, prefixComponent: bundle.identifier) + return imageRef.destinationURL(for: variant.lastPathComponent, prefixComponent: bundle.id.rawValue) } imageRef.asset.metadata = .init(uniqueKeysWithValues: imageRef.asset.metadata.map { key, value in - return (imageRef.destinationURL(for: key.lastPathComponent, prefixComponent: bundle.identifier), value) + return (imageRef.destinationURL(for: key.lastPathComponent, prefixComponent: bundle.id.rawValue), value) }) return imageRef as RenderReference } - let encoded = try RenderJSONEncoder.makeEncoder(assetPrefixComponent: bundle.identifier).encode(summary) + let encoded = try RenderJSONEncoder.makeEncoder(assetPrefixComponent: bundle.id.rawValue).encode(summary) let decoded = try JSONDecoder().decode(LinkDestinationSummary.self, from: encoded) XCTAssertEqual(decoded, summary) } @@ -436,7 +436,7 @@ class ExternalLinkableTests: XCTestCase { // Check a symbol that's represented as a class in both Swift and Objective-C do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -495,7 +495,7 @@ class ExternalLinkableTests: XCTestCase { // Check the Swift version of a symbol that's represented differently in different languages do { - let symbolReference = ResolvedTopicReference(bundleIdentifier: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(id: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -627,7 +627,7 @@ class ExternalLinkableTests: XCTestCase { let decoded = try JSONDecoder().decode(LinkDestinationSummary.self, from: legacyData) - XCTAssertEqual(decoded.referenceURL, ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/ClassName", sourceLanguage: .swift).url) + XCTAssertEqual(decoded.referenceURL, ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/ClassName", sourceLanguage: .swift).url) XCTAssertEqual(decoded.platforms?.count, 1) XCTAssertEqual(decoded.platforms?.first?.name, "PlatformName") XCTAssertEqual(decoded.platforms?.first?.introduced, "1.0") @@ -727,7 +727,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) diff --git a/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift b/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift index b3f3ff995..16cb6bd05 100644 --- a/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2022 Apple Inc. and the Swift project authors + Copyright (c) 2022-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -31,7 +31,7 @@ class DocumentationNodeTests: XCTestCase { let article = Article(markup: Document(parsing: articleSource, options: []), metadata: nil, redirects: nil, options: [:]) let node = try DocumentationNode( - reference: ResolvedTopicReference(bundleIdentifier: "org.swift.docc", path: "/blah", sourceLanguage: .swift), + reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), article: article ) XCTAssertEqual(node.anchorSections.count, 5) diff --git a/Tests/SwiftDocCTests/Model/IdentifierTests.swift b/Tests/SwiftDocCTests/Model/IdentifierTests.swift index be95cbb79..d172513f8 100644 --- a/Tests/SwiftDocCTests/Model/IdentifierTests.swift +++ b/Tests/SwiftDocCTests/Model/IdentifierTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -73,15 +73,15 @@ class IdentifierTests: XCTestCase { XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") // Add the same reference repeatedly - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should still only have one cached reference because the same reference was created repeatedly") // Add another reference - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/other-page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/other-page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 2, "Should have cached another reference because two different references with this bundle identifier has been created") // Purge and repeat @@ -91,7 +91,7 @@ class IdentifierTests: XCTestCase { ResolvedTopicReference.enableReferenceCaching(for: bundleID) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") } @@ -99,21 +99,21 @@ class IdentifierTests: XCTestCase { let bundleID: DocumentationBundle.Identifier = #function XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "References for this bundle shouldn't exist because caching is not enabled by default") - _ = ResolvedTopicReference(bundleIdentifier: bundleID.rawValue, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "After creating a reference in this bundle, references still shouldn't exist because caching is not enabled by default") } func testReferenceInitialPathComponents() { - let ref1 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/", sourceLanguage: .swift) + let ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.pathComponents, ["/"]) - let ref2 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/MyClass", sourceLanguage: .swift) + let ref2 = ResolvedTopicReference(id: "bundle", path: "/MyClass", sourceLanguage: .swift) XCTAssertEqual(ref2.pathComponents, ["/", "MyClass"]) - let ref3 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) + let ref3 = ResolvedTopicReference(id: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) XCTAssertEqual(ref3.pathComponents, ["/", "MyClass", "myFunction"]) } func testReferenceUpdatedPathComponents() { - var ref1 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/", sourceLanguage: .swift) + var ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.pathComponents, ["/"]) ref1 = ref1.appendingPath("MyClass") XCTAssertEqual(ref1.pathComponents, ["/", "MyClass"]) @@ -124,16 +124,16 @@ class IdentifierTests: XCTestCase { } func testReferenceInitialAbsoluteString() { - let ref1 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/", sourceLanguage: .swift) + let ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.absoluteString, "doc://bundle/") - let ref2 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/MyClass", sourceLanguage: .swift) + let ref2 = ResolvedTopicReference(id: "bundle", path: "/MyClass", sourceLanguage: .swift) XCTAssertEqual(ref2.absoluteString, "doc://bundle/MyClass") - let ref3 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) + let ref3 = ResolvedTopicReference(id: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) XCTAssertEqual(ref3.absoluteString, "doc://bundle/MyClass/myFunction") } func testReferenceUpdatedAbsoluteString() { - var ref1 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/", sourceLanguage: .swift) + var ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.absoluteString, "doc://bundle/") ref1 = ref1.appendingPath("MyClass") XCTAssertEqual(ref1.absoluteString, "doc://bundle/MyClass") @@ -144,7 +144,7 @@ class IdentifierTests: XCTestCase { } func testResolvedTopicReferenceDoesNotCopyStorageIfNotModified() { - let reference1 = ResolvedTopicReference(bundleIdentifier: "bundle", path: "/", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) let reference2 = reference1 XCTAssertEqual( @@ -155,7 +155,7 @@ class IdentifierTests: XCTestCase { func testWithSourceLanguages() { let swiftReference = ResolvedTopicReference( - bundleIdentifier: "bundle", + id: "bundle", path: "/", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift index bfa303902..4c1e38a90 100644 --- a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift +++ b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift @@ -51,7 +51,7 @@ class LineHighlighterTests: XCTestCase { let catalog = Self.makeCatalog(tutorial: tutorialFile, codeFiles: codeFiles) let (bundle, context) = try loadBundle(catalog: catalog) - let tutorialReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) let tutorial = try context.entity(with: tutorialReference).semantic as! Tutorial let section = tutorial.sections.first! return LineHighlighter(context: context, tutorialSection: section, tutorialReference: tutorialReference).highlights diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index bc7e93861..a18356a3a 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -26,7 +26,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: `YES` if doing something was successful, or `NO` if an error occurred. // - (void)doSomethingWith:(NSInteger)someValue error:(NSError **)error; do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -47,7 +47,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: Some string. If an error occurs, this method returns `nil` and assigns an appropriate error object to the `error` parameter. // - (nullable NSString *)returnSomethingAndReturnError:(NSError **)error; do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -68,7 +68,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func doSomething(with someValue: Int) throws { } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -93,7 +93,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func returnSomething() throws -> String { "" } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -435,7 +435,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -492,7 +492,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -534,7 +534,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift index 9b8f61f48..f49ab4c9d 100644 --- a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift +++ b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift @@ -83,7 +83,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testAbsenceOfPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) // Check that the `Possible Values` section is not rendered if the symbol don't define any possible value. @@ -92,7 +92,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testUndocumentedPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let possibleValuesSection = try XCTUnwrap(try converter.convert(node).primaryContentSections.first(where: { $0.kind == .possibleValues}) as? PossibleValuesRenderSection) let possibleValues: [PossibleValuesRenderSection.NamedValue] = possibleValuesSection.values @@ -116,7 +116,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) @@ -136,7 +136,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) diff --git a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift index 7e7f15ca6..41d3ef796 100644 --- a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -68,7 +68,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTables() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -109,7 +109,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableSpans() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | @@ -162,7 +162,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableColumnAlignments() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | four | @@ -204,7 +204,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that a table with `nil` alignments and a table with all-unset alignments still compare as equal. func testRenderedTableEquality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -230,7 +230,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that two tables with otherwise-identical contents but different column alignments compare as unequal. func testRenderedTableInequality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let decodedTableWithUnsetColumns: RenderBlockContent.Table do { @@ -277,7 +277,7 @@ class RenderContentMetadataTests: XCTestCase { func testStrikethrough() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ~~Striken~~ text. @@ -300,7 +300,7 @@ class RenderContentMetadataTests: XCTestCase { func testHeadingAnchorShouldBeEncoded() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ## テスト diff --git a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift index 3ae753a76..464a9925b 100644 --- a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -14,7 +14,7 @@ import XCTest class RenderHierarchyTranslatorTests: XCTestCase { func test() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let technologyReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let technologyReference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) var translator = RenderHierarchyTranslator(context: context, bundle: bundle) let renderHierarchy = translator.visitTutorialTableOfContentsNode(technologyReference)?.hierarchy @@ -100,7 +100,7 @@ class RenderHierarchyTranslatorTests: XCTestCase { } // Get a translated render node - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) let renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift index 323bcfaa4..56b584d84 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift @@ -13,7 +13,7 @@ import XCTest class RenderNodeDiffingBundleTests: XCTestCase { let testBundleName = "TestBundle" - let testBundleIdentifier = "org.swift.docc.example" + let testBundleID: DocumentationBundle.Identifier = "org.swift.docc.example" func testDiffSymbolFromBundleWithDiscussionSectionRemoved() throws { let pathToSymbol = "/documentation/MyKit" @@ -29,7 +29,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToSymbol, modification: modification) @@ -57,7 +57,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToArticle, modification: modification) @@ -90,7 +90,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToArticle, modification: modification) @@ -122,7 +122,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToSymbol, modification: modification) @@ -151,7 +151,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToSymbol, modification: modification) @@ -189,7 +189,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToSymbol, modification: modification) @@ -228,7 +228,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToSymbol, modification: modification) @@ -264,7 +264,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { } let differences = try getDiffsFromModifiedDocument(bundleName: testBundleName, - bundleIdentifier: testBundleIdentifier, + bundleID: testBundleID, topicReferencePath: pathToArticle, modification: modification) @@ -299,12 +299,12 @@ class RenderNodeDiffingBundleTests: XCTestCase { } func getDiffsFromModifiedDocument(bundleName: String, - bundleIdentifier: String, + bundleID: DocumentationBundle.Identifier, topicReferencePath: String, modification: @escaping (URL) throws -> () ) throws -> JSONPatchDifferences { let (bundleOriginal, contextOriginal) = try testBundleAndContext(named: bundleName) - let nodeOriginal = try contextOriginal.entity(with: ResolvedTopicReference(bundleIdentifier: bundleIdentifier, + let nodeOriginal = try contextOriginal.entity(with: ResolvedTopicReference(id: bundleID, path: topicReferencePath, sourceLanguage: .swift)) var renderContext = RenderContext(documentationContext: contextOriginal, bundle: bundleOriginal) @@ -316,7 +316,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { let (_, bundleModified, contextModified) = try testBundleAndContext(copying: bundleName) { url in try modification(url) } - let nodeModified = try contextModified.entity(with: ResolvedTopicReference(bundleIdentifier: bundleIdentifier, + let nodeModified = try contextModified.entity(with: ResolvedTopicReference(id: bundleID, path: topicReferencePath, sourceLanguage: .swift)) renderContext = RenderContext(documentationContext: contextModified, bundle: bundleModified) diff --git a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift index c8c824973..e32a51c45 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -14,7 +14,7 @@ import Markdown class RenderNodeSerializationTests: XCTestCase { func testRoundTrip() throws { - let inputIdentifier = ResolvedTopicReference(bundleIdentifier: "com.example.docc", path: "/example", sourceLanguage: .swift) + let inputIdentifier = ResolvedTopicReference(id: "com.example.docc", path: "/example", sourceLanguage: .swift) var inputNode = RenderNode(identifier: inputIdentifier, kind: .tutorial) let introSection = IntroRenderSection(title: "Basic Augmented Reality App") @@ -93,7 +93,7 @@ class RenderNodeSerializationTests: XCTestCase { func testBundleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -116,7 +116,7 @@ class RenderNodeSerializationTests: XCTestCase { func testTutorialArticleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") @@ -141,7 +141,7 @@ class RenderNodeSerializationTests: XCTestCase { typealias JSONDictionary = [String: Any] let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -193,7 +193,7 @@ class RenderNodeSerializationTests: XCTestCase { func testDiffAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") diff --git a/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift b/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift index f08fa8bdf..0d30c21bb 100644 --- a/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift +++ b/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -13,7 +13,7 @@ import XCTest class ResourceReferenceTests: XCTestCase { func testPathWithSectionFragment() throws { - let ref = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/Test-Bundle/Tutorial1", sourceLanguage: .swift) + let ref = ResolvedTopicReference(id: "org.swift.docc.example", path: "/Test-Bundle/Tutorial1", sourceLanguage: .swift) XCTAssertEqual(ref.absoluteString, "doc://org.swift.docc.example/Test-Bundle/Tutorial1") let refAdvanced = ref.withFragment("fragment") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift index 0f94b384a..0fd0211bd 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift @@ -444,7 +444,7 @@ class SemaToRenderNodeMixedLanguageTests: XCTestCase { """.write(to: url.appendingPathComponent("bar.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssert(context.problems.isEmpty, "Encountered unexpected problems: \(context.problems)") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift index 5f23c39a3..69ff95083 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift @@ -17,7 +17,7 @@ import SwiftDocCTestUtilities class SemaToRenderNodeTests: XCTestCase { func testCompileTutorial() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -46,7 +46,7 @@ class SemaToRenderNodeTests: XCTestCase { XCTAssertFalse(jsonString.contains("This is a comment")) } - XCTAssertEqual(renderNode.identifier, ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + XCTAssertEqual(renderNode.identifier, ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) XCTAssertEqual(renderNode.sections.count, 4) guard let intro = renderNode.sections.first as? IntroRenderSection else { @@ -404,7 +404,7 @@ class SemaToRenderNodeTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func assertTutorialWithPath(_ tutorialPath: String, hasBackground backgroundIdentifier: String) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: tutorialPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: tutorialPath, sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -432,7 +432,7 @@ class SemaToRenderNodeTests: XCTestCase { func testCompileTutorialArticle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) let article = node.semantic as! TutorialArticle @@ -570,7 +570,7 @@ class SemaToRenderNodeTests: XCTestCase { } private func assertCompileOverviewWithNoVolumes(bundle: DocumentationBundle, context: DocumentationContext, expectedProblemsCount: Int = 0) throws { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -807,7 +807,7 @@ class SemaToRenderNodeTests: XCTestCase { try text.write(to: overviewURL, atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -941,7 +941,7 @@ class SemaToRenderNodeTests: XCTestCase { try JSONEncoder().encode(graph).write(to: graphURL) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Verify that `MyProtocol` the symbol is loaded in the topic graph, but the `MyProtocol` sidecar article was removed. let matches = context.knownPages.filter({ reference -> Bool in @@ -1175,7 +1175,7 @@ class SemaToRenderNodeTests: XCTestCase { func testCompileSymbolWithExternalReferences() throws { class TestSymbolResolver: GlobalExternalSymbolResolver { func symbolReferenceAndEntity(withPreciseIdentifier preciseIdentifier: String) -> (ResolvedTopicReference, LinkResolver.ExternalEntity)? { - let reference = ResolvedTopicReference(bundleIdentifier: "com.test.external.symbols", path: "/\(preciseIdentifier)", sourceLanguage: .objectiveC) + let reference = ResolvedTopicReference(id: "com.test.external.symbols", path: "/\(preciseIdentifier)", sourceLanguage: .objectiveC) let entity = LinkResolver.ExternalEntity( topicRenderReference: TopicRenderReference( @@ -1198,7 +1198,7 @@ class SemaToRenderNodeTests: XCTestCase { func resolve(_ reference: TopicReference) -> TopicReferenceResolutionResult { .success( ResolvedTopicReference( - bundleIdentifier: "com.test.external", + id: "com.test.external", path: reference.url!.path, sourceLanguage: .swift ) @@ -1326,7 +1326,7 @@ class SemaToRenderNodeTests: XCTestCase { // Check for constraints in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1346,7 +1346,7 @@ class SemaToRenderNodeTests: XCTestCase { }.joined(), "Label is Text, Observer inherits NSObject, and S conforms to StringProtocol.") // Check for constraints in render references - let parent = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let parent = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let parentSymbol = parent.semantic as! Symbol var parentTranslator = RenderNodeTranslator(context: context, bundle: bundle, identifier: parent.reference) @@ -1379,7 +1379,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnConformingType() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1401,7 +1401,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnProtocol() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1423,7 +1423,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderReferenceResolving() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1488,7 +1488,7 @@ class SemaToRenderNodeTests: XCTestCase { func testAvailabilityMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1549,7 +1549,7 @@ class SemaToRenderNodeTests: XCTestCase { } }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1576,7 +1576,7 @@ class SemaToRenderNodeTests: XCTestCase { func testMediaReferencesWithSpaces() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -1637,7 +1637,7 @@ Document @1:1-11:19 markup.debugDescription(options: .printSourceLocations)) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1679,7 +1679,7 @@ Document markup.debugDescription()) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1702,7 +1702,7 @@ Document """ let document = Document(parsing: markupSource, options: []) - let node = DocumentationNode(reference: ResolvedTopicReference(bundleIdentifier: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) + let node = DocumentationNode(reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) let (bundle, context) = try testBundleAndContext(named: "TestBundle") var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1711,7 +1711,7 @@ Document func testCompileSymbolMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1819,7 +1819,7 @@ Document try content.write(to: targetURL.appendingPathComponent("article2.md"), atomically: true, encoding: .utf8) let (_, bundle, context) = try loadBundle(from: targetURL) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return translator.visit(article) as! RenderNode @@ -1907,7 +1907,7 @@ Document let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) return (bundle, context, reference) } @@ -2061,14 +2061,14 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: nil, deprecatedVersion: .init(major: 13, minor: 0, patch: 0), obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2084,7 +2084,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2092,7 +2092,7 @@ Document ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2108,7 +2108,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: true, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2116,7 +2116,7 @@ Document ]) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2131,7 +2131,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2151,7 +2151,7 @@ Document func testRenderMetadataExtendedModule() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2165,7 +2165,7 @@ Document // Verify that the render reference to a required symbol includes the 'required' key and the number of default implementations provided. do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2178,7 +2178,7 @@ Document // Verify that a required symbol includes a required metadata and default implementations do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2198,7 +2198,7 @@ Document // Verify that a required symbol does not include default implementations in Topics groups do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2213,7 +2213,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2242,7 +2242,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2261,7 +2261,7 @@ Document func testDocumentationRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2281,7 +2281,7 @@ Document func testTutorialsRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) let symbol = node.semantic as! TutorialTableOfContents var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2301,7 +2301,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol // Subheading with trailing "\n" @@ -2323,7 +2323,7 @@ Document func testRenderManualSeeAlsoInArticles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2346,7 +2346,7 @@ Document func testSafeSectionAnchorNames() throws { // Check that heading's anchor was safe-ified let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2367,7 +2367,7 @@ Document func testDuplicateNavigatorTitleIsRemoved() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2383,7 +2383,7 @@ Document func testNonDuplicateNavigatorTitleIsRendered() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2440,7 +2440,7 @@ Document """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -2461,7 +2461,7 @@ Document _ = translator.visit(tutorialTableOfContents) do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2532,7 +2532,7 @@ Document """.write(to: url.appendingPathComponent("TestTutorial.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2576,8 +2576,8 @@ Document XCTAssertEqual(Array(asides.content.dropFirst()), self.asidesStressTest) } - let dashReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) - let quoteReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) + let dashReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) + let quoteReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) try testReference(dashReference) try testReference(quoteReference) @@ -2587,7 +2587,7 @@ Document func testOriginMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let origin = try XCTUnwrap(symbol.origin) @@ -2609,7 +2609,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2636,7 +2636,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2662,7 +2662,7 @@ Document return p.diagnostic.summary == "Resource 'my-inherited-image.png' couldn't be found" })) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2691,7 +2691,7 @@ Document """.write(to: url.appendingPathComponent("inherited.md"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2836,7 +2836,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json")) }) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2866,7 +2866,7 @@ Document problem.diagnostic.summary.contains("my-inherited-image.png") })) - let myFuncReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2901,7 +2901,7 @@ Document func testNonDocumentedSymbolNilAbstract() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3016,7 +3016,7 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -3057,9 +3057,9 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit", sourceLanguage: .swift) - let protocolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) - let functionReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let protocolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let functionReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) // Verify the MyKit module @@ -3141,13 +3141,13 @@ Document // Verify that the inherited symbol got a path that accounts for the collision between // the struct `B` and the property `b`. - let inheritedSymbolReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) + let inheritedSymbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) XCTAssertNoThrow(try context.entity(with: inheritedSymbolReference)) // Verify that the inherited symbol is automatically curated with its correct // reference path under the inherited symbols API collection - let equatableImplementationsReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) + let equatableImplementationsReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) let equatableImplementationsNode = try context.entity(with: equatableImplementationsReference) let equatableImplementationsArticle = try XCTUnwrap(equatableImplementationsNode.semantic as? Article) let group = try XCTUnwrap(equatableImplementationsArticle.automaticTaskGroups.first) @@ -3179,7 +3179,7 @@ Document } """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") return @@ -3224,7 +3224,7 @@ Document ) let moduleReference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3267,7 +3267,7 @@ Document ) let articleReference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3436,7 +3436,7 @@ Document } do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) let node = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -3487,7 +3487,7 @@ Document let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Model/TaskGroupTests.swift b/Tests/SwiftDocCTests/Model/TaskGroupTests.swift index 1f2699ebe..688cca95c 100644 --- a/Tests/SwiftDocCTests/Model/TaskGroupTests.swift +++ b/Tests/SwiftDocCTests/Model/TaskGroupTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -69,7 +69,7 @@ class SectionExtractionTests: XCTestCase { } private func testNode(with document: Document) -> DocumentationNode { - return DocumentationNode(reference: ResolvedTopicReference(bundleIdentifier: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) + return DocumentationNode(reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) } func testSection() { diff --git a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift index 37b9586f5..48a33fd16 100644 --- a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -30,7 +30,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -61,7 +61,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -104,7 +104,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -121,7 +121,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that articles get same automatic See Also sections as symbols do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -171,7 +171,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -184,7 +184,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that article without options directive still gets automatic See Also sections do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -235,7 +235,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -248,7 +248,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that article without options directive still gets automatic See Also sections do { - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -286,7 +286,7 @@ class AutomaticSeeAlsoTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: bundleURL) // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "MyKit", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "MyKit", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift index a00e208eb..d4f143b73 100644 --- a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift @@ -24,7 +24,7 @@ class AvailabilityRenderOrderTests: XCTestCase { try? FileManager.default.removeItem(at: bundleURL) } - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift index 637baa216..66a89b05f 100644 --- a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -40,7 +40,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -70,7 +70,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -99,7 +99,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -129,7 +129,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -159,7 +159,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -190,7 +190,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -220,7 +220,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -258,7 +258,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift index 145cd912c..4de3f9993 100644 --- a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -135,7 +135,7 @@ class DeclarationsRenderSectionTests: XCTestCase { func testAlternateDeclarations() throws { let (bundle, context) = try testBundleAndContext(named: "AlternateDeclarations") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AlternateDeclarations/MyClass/present(completion:)", sourceLanguage: .swift ) @@ -186,7 +186,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload1(param: Set) {} // func overload1(param: [Int: Int]) {} let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/FancyOverloads/overload1(param:)", sourceLanguage: .swift ) @@ -237,7 +237,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload2(p1: (Int) -> Int?, p2: Int) {} // func overload2(p1: ((Int) -> Int)?, p2: Int) {} // <- overload group let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/FancyOverloads/overload2(p1:p2:)", sourceLanguage: .swift ) @@ -292,7 +292,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload3(_ p: [T: T]) {} // func overload3(_ p: [K: V]) {} let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/FancyOverloads/overload3(_:)", sourceLanguage: .swift ) @@ -342,7 +342,7 @@ class DeclarationsRenderSectionTests: XCTestCase { for hash in ["7eht8", "8p1lo", "858ja"] { let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/FancyOverloads/overload3(_:)-\(hash)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift index 913080351..c4e79ad5e 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift @@ -71,7 +71,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is used for modules do { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -81,7 +81,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is used for symbols with no explicit availability do { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-3743d", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-3743d", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -91,7 +91,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is NOT used for symbols with explicit availability do { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -185,7 +185,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the module availability is not "beta" for the "macOS" platform (since 10.15.1 != 10.16) do { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -205,7 +205,7 @@ class DefaultAvailabilityTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) do { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) // Add some available and unavailable platforms to the symbol @@ -336,7 +336,7 @@ class DefaultAvailabilityTests: XCTestCase { let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) @@ -665,7 +665,7 @@ class DefaultAvailabilityTests: XCTestCase { XCTAssertNotNil(availability.first(where: { $0.domain?.rawValue == "iOS" })) XCTAssertEqual(availability.first(where: { $0.domain?.rawValue == "iOS" })?.introducedVersion, nil) // Verify we remove the version from the module availability information. - var identifier = ResolvedTopicReference(bundleIdentifier: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) + var identifier = ResolvedTopicReference(id: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) var node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) var renderNode = translator.visit(node.semantic) as! RenderNode @@ -708,7 +708,7 @@ class DefaultAvailabilityTests: XCTestCase { XCTAssertEqual(availability.first(where: { $0.domain?.rawValue == "watchOS" })?.introducedVersion, nil) // Verify the module availability shows as expected. - identifier = ResolvedTopicReference(bundleIdentifier: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) + identifier = ResolvedTopicReference(id: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) node = try context.entity(with: identifier) translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift index 73aecb1dc..e0c14c0d8 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift @@ -25,7 +25,7 @@ class DefaultCodeBlockSyntaxTests: XCTestCase { override func setUpWithError() throws { func renderSection(for bundle: DocumentationBundle, in context: DocumentationContext) throws -> ContentRenderSection { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -42,7 +42,7 @@ class DefaultCodeBlockSyntaxTests: XCTestCase { testBundleWithoutLanguageDefault = DocumentationBundle( info: DocumentationBundle.Info( displayName: testBundleWithLanguageDefault.displayName, - id: DocumentationBundle.Identifier(rawValue: testBundleWithLanguageDefault.identifier), + id: testBundleWithLanguageDefault.id, defaultCodeListingLanguage: nil ), baseURL: testBundleWithLanguageDefault.baseURL, diff --git a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift index ea0449ba1..c78d6e4c2 100644 --- a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -32,7 +32,7 @@ class DeprecationSummaryTests: XCTestCase { /// and it's preferred over the original deprecation note in the code docs. func testAuthoredDeprecatedSummary() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -63,7 +63,7 @@ class DeprecationSummaryTests: XCTestCase { }) // Verify the deprecation is still rendered. - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -83,7 +83,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass", sourceLanguage: .swift ) @@ -115,7 +115,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) @@ -137,7 +137,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass/init()", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass/coolFunc()", sourceLanguage: .swift ) @@ -195,7 +195,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/CoolFramework/CoolClass/init(config:cache:)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift b/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift index 47c542d53..7d6a829ea 100644 --- a/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift @@ -146,7 +146,7 @@ private extension DocumentationContentRendererTests { var nodeWithSubheadingAndNavigatorVariants: DocumentationNode { var node = DocumentationNode( reference: ResolvedTopicReference( - bundleIdentifier: "org.swift.example", + id: "org.swift.example", path: "/documentation/class", fragment: nil, sourceLanguage: .swift @@ -198,7 +198,7 @@ private extension DocumentationContentRendererTests { ]), roleHeadingVariants: .init(swiftVariant: ""), platformNameVariants: .init(swiftVariant: nil), - moduleReference: ResolvedTopicReference(bundleIdentifier: "", path: "", sourceLanguage: .swift), // This information isn't used anywhere. + moduleReference: ResolvedTopicReference(id: "", path: "", sourceLanguage: .swift), // This information isn't used anywhere. externalIDVariants: .init(swiftVariant: nil), accessLevelVariants: .init(swiftVariant: nil), availabilityVariants: .init(swiftVariant: Availability(availability: [])), diff --git a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift index 77ee06a25..41965079b 100644 --- a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -15,7 +15,7 @@ import Markdown public class ExternalLinkTitleTests: XCTestCase { private func getTranslatorAndBlockContentForMarkup(_ markupSource: String) throws -> (translator: RenderNodeTranslator, content: [RenderBlockContent]) { let document = Document(parsing: markupSource, options: [.parseBlockDirectives, .parseSymbolLinks]) - let testReference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc", path: "/test", sourceLanguage: .swift) + let testReference = ResolvedTopicReference(id: "org.swift.docc", path: "/test", sourceLanguage: .swift) let node = DocumentationNode(reference: testReference, kind: .article, sourceLanguage: .swift, diff --git a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift index ff1f4a680..f61ca7414 100644 --- a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift @@ -19,12 +19,12 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift ) let mentioningArticle = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift ) @@ -42,7 +42,7 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/MyClass/myFunction()", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift index 0cbe9c790..d558b20ae 100644 --- a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023 Apple Inc. and the Swift project authors + Copyright (c) 2023-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -18,7 +18,7 @@ class PageKindTests: XCTestCase { private func generateRenderNodeFromBundle(bundleName: String, resolvedTopicPath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: bundleName) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: resolvedTopicPath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift index fbc8f0080..1a5bc1491 100644 --- a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift @@ -36,7 +36,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -55,7 +55,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromExtension() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -73,7 +73,7 @@ class PlatformAvailabilityTests: XCTestCase { func testMultiplePlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -101,7 +101,7 @@ class PlatformAvailabilityTests: XCTestCase { func testArbitraryPlatformAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AvailabilityBundle/ArbitraryPlatforms", sourceLanguage: .swift ) @@ -127,7 +127,7 @@ class PlatformAvailabilityTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "AvailabilityOverrideBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -189,7 +189,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -221,7 +221,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift index 38201a0e7..c5772c22c 100644 --- a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift @@ -332,7 +332,7 @@ class RESTSymbolsTests: XCTestCase { ] + extraFiles ) let (_, bundle, context) = try loadBundle(from: (try createTempFolder(content: [exampleDocumentation]))) - let moduleReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let moduleSymbol = try XCTUnwrap((try context.entity(with: moduleReference)).semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: moduleReference) let renderNode = translator.visit(moduleSymbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift index e5740686f..7caec65c1 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift @@ -40,7 +40,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -67,7 +67,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -97,7 +97,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift index 74f09d48a..6c397f2c9 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift @@ -16,7 +16,7 @@ import XCTest class RenderContentCompilerTests: XCTestCase { func testLinkOverrideTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ [Example](http://example.com) @@ -134,7 +134,7 @@ class RenderContentCompilerTests: XCTestCase { func testLineBreak() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" Backslash before new line\ @@ -199,7 +199,7 @@ class RenderContentCompilerTests: XCTestCase { func testThematicBreak() throws { let (bundle, context) = try testBundleAndContext() - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" diff --git a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift index c16d5a031..7e5cc6276 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -100,7 +100,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -127,7 +127,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -149,7 +149,7 @@ class RenderMetadataTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency/AmbiguousType", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency/AmbiguousType", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertEqual(renderNode.metadata.modules?.first?.name, "BundleWithRelativePathAmbiguity") diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift index 773705462..f85f4ebdc 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -35,7 +35,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModules() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(bundleIdentifier: resolvedTopicReference.bundleIdentifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -51,7 +51,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModulesWithBystanderModule() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(bundleIdentifier: resolvedTopicReference.bundleIdentifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -79,7 +79,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModulesWithDifferentBystanderModule() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(bundleIdentifier: resolvedTopicReference.bundleIdentifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Extended Module Title") context.preResolveModuleNames() }, @@ -125,7 +125,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testPlatformsVariantsDefaultAvailability() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(bundleIdentifier: resolvedTopicReference.bundleIdentifier, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -665,7 +665,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { // Set up an Objective-C title for MyProtocol. let myFunctionNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", fragment: nil, sourceLanguage: .swift @@ -716,7 +716,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { // Set up an Objective-C title for MyProtocol. let myFunctionNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", fragment: nil, sourceLanguage: .swift @@ -755,7 +755,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { configureContext: { context, reference in try makeSymbolAvailableInSwiftAndObjectiveC( symbolPath: "/documentation/MyKit/MyProtocol", - bundleIdentifier: reference.bundleIdentifier, + id: reference.id, context: context ) }, @@ -887,7 +887,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { Implementation( reference: .successfullyResolved( ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift @@ -954,7 +954,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { configureContext: { context, reference in try makeSymbolAvailableInSwiftAndObjectiveC( symbolPath: "/documentation/MyKit/MyProtocol", - bundleIdentifier: reference.bundleIdentifier, + id: reference.id, context: context ) }, @@ -1146,7 +1146,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let myFunctionNode = try context.entity( with: ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift @@ -1188,7 +1188,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: bundleName) let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -1225,7 +1225,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") let identifier = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -1298,7 +1298,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { destinations: [ TopicReference.successfullyResolved( ResolvedTopicReference( - bundleIdentifier: "org.swift.docc.example", + id: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift @@ -1324,14 +1324,10 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { private func makeSymbolAvailableInSwiftAndObjectiveC( symbolPath: String, - bundleIdentifier: String, + id: DocumentationBundle.Identifier, context: DocumentationContext ) throws { - let reference = ResolvedTopicReference( - bundleIdentifier: bundleIdentifier, - path: symbolPath, - sourceLanguage: .swift - ) + let reference = ResolvedTopicReference(id: id, path: symbolPath, sourceLanguage: .swift) context.documentationCache[reference]?.availableSourceLanguages = [.swift, .objectiveC] } diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift index e324d2805..f9e07371b 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift @@ -19,7 +19,7 @@ class RenderNodeTranslatorTests: XCTestCase { private func findDiscussion(forSymbolPath: String, configureBundle: ((URL) throws -> Void)? = nil) throws -> ContentRenderSection? { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", configureBundle: configureBundle) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: forSymbolPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: forSymbolPath, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -291,7 +291,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let node = try context.entity(with: reference) let article = try XCTUnwrap(node.semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -341,7 +341,7 @@ class RenderNodeTranslatorTests: XCTestCase { let article = try XCTUnwrap( Article(from: document.root, source: nil, for: bundle, in: context, problems: &problems) ) - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/taskgroups", fragment: nil, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/taskgroups", fragment: nil, sourceLanguage: .swift) context.documentationCache[reference] = try DocumentationNode(reference: reference, article: article) let topicGraphNode = TopicGraph.Node(reference: reference, kind: .article, source: .file(url: URL(fileURLWithPath: "/path/to/article.md")), title: "My Article") context.topicGraph.addNode(topicGraphNode) @@ -375,7 +375,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -406,7 +406,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -440,7 +440,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -451,7 +451,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -462,7 +462,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -502,7 +502,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -525,7 +525,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -553,7 +553,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -564,7 +564,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -575,7 +575,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -605,7 +605,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify "Default Implementations" group on the implementing type do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -624,7 +624,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify automatically generated api collection do { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -653,7 +653,7 @@ class RenderNodeTranslatorTests: XCTestCase { try? FileManager.default.copyItem(at: fancyProtocolSGFURL, to: url.appendingPathComponent("FancyProtocol.symbols.json")) } - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -856,7 +856,7 @@ class RenderNodeTranslatorTests: XCTestCase { func loadRenderNode(at path: String, in bundleURL: URL) throws -> RenderNode { let (_, bundle, context) = try loadBundle(from: bundleURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -865,7 +865,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testAutomaticTaskGroupTopicsAreSorted() throws { let (bundle, context) = try testBundleAndContext(named: "DefaultImplementations") - let structReference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) + let structReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) let structNode = try context.entity(with: structReference) let symbol = try XCTUnwrap(structNode.semantic as? Symbol) @@ -899,7 +899,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -927,7 +927,7 @@ class RenderNodeTranslatorTests: XCTestCase { // First verify that `SideKit` page does not contain render reference to `SideKit/SideClass/Element`. let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -935,7 +935,7 @@ class RenderNodeTranslatorTests: XCTestCase { let renderNode = try XCTUnwrap(translator.visitSymbol(symbol) as? RenderNode) // No render reference to `Element` - XCTAssertFalse(renderNode.references.keys.contains("doc://\(bundle.identifier)/documentation/SideKit/SideClass/Element")) + XCTAssertFalse(renderNode.references.keys.contains("doc://\(bundle.id)/documentation/SideKit/SideClass/Element")) } do { @@ -947,7 +947,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -955,13 +955,13 @@ class RenderNodeTranslatorTests: XCTestCase { let renderNode = try XCTUnwrap(translator.visitSymbol(symbol) as? RenderNode) // There is a render reference to `Element` - XCTAssertTrue(renderNode.references.keys.contains("doc://\(bundle.identifier)/documentation/SideKit/SideClass/Element")) + XCTAssertTrue(renderNode.references.keys.contains("doc://\(bundle.id)/documentation/SideKit/SideClass/Element")) } } func testSnippetToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -991,7 +991,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1015,7 +1015,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testNestedSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1046,7 +1046,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceTrimsIndentation() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1072,7 +1072,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRowAndColumn() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1101,7 +1101,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSmall() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1129,7 +1129,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTabNavigator() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/BestBook/TabNavigatorArticle", sourceLanguage: .swift ) @@ -1166,7 +1166,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRenderNodeMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1242,7 +1242,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testPageColorMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1258,7 +1258,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTitleHeadingMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1340,7 +1340,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) @@ -1433,7 +1433,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) diff --git a/Tests/SwiftDocCTests/Rendering/RoleTests.swift b/Tests/SwiftDocCTests/Rendering/RoleTests.swift index af417936a..e3cd507ce 100644 --- a/Tests/SwiftDocCTests/Rendering/RoleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RoleTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -29,7 +29,7 @@ class RoleTests: XCTestCase { // Compile docs and verify contents for (path, expectedRole) in expectedRoles { - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift) do { let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -45,7 +45,7 @@ class RoleTests: XCTestCase { func testDocumentationRenderReferenceRoles() throws { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -58,7 +58,7 @@ class RoleTests: XCTestCase { func testTutorialsRenderReferenceRoles() throws { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") - let identifier = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift index 921b80b76..b73a6e1d4 100644 --- a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift +++ b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -128,7 +128,7 @@ class SampleDownloadTests: XCTestCase { private func renderNodeFromSampleBundle(at referencePath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: "SampleBundle") let reference = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: referencePath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index 983930800..2872bb265 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -87,7 +87,7 @@ class TermListTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: ["com.external.testbundle": resolver]) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -161,7 +161,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - term First term : A paragraph that @@ -204,7 +204,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - Not a term list, and diff --git a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift index 25ad3d776..a77676ba8 100644 --- a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift @@ -18,11 +18,11 @@ class ArticleSymbolMentionsTests: XCTestCase { /// Test that the recording abstraction for ``ArticleSymbolMentions`` works as expected. func testArticlesMentioningSymbol() throws { let article = ResolvedTopicReference( - bundleIdentifier: "org.swift.anything", + id: "org.swift.anything", path: "/article", sourceLanguage: .swift ) - let symbol = ResolvedTopicReference(bundleIdentifier: "org.swift.anything", path: "/Thing", sourceLanguage: .swift) + let symbol = ResolvedTopicReference(id: "org.swift.anything", path: "/Thing", sourceLanguage: .swift) var mentions = ArticleSymbolMentions() XCTAssertTrue(mentions.articlesMentioning(symbol).isEmpty) @@ -47,11 +47,11 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertEqual(1, context.articleSymbolMentions.mentions.count) let mentioningArticle = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift) let mentionedSymbol = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) @@ -68,7 +68,7 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertTrue(context.articleSymbolMentions.mentions.isEmpty) let mentionedSymbol = ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index aeda13f54..075dfccbf 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -89,7 +89,7 @@ class DoxygenTests: XCTestCase { ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) // Verify the expected content in the in-memory model let node = try context.entity(with: reference) diff --git a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift index 3d47117d2..5518df0e1 100644 --- a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift @@ -395,7 +395,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeNode() throws { let title = "unreferenced-tutorial" - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: URL(fileURLWithPath: "/path/to/\(title)")), title: title) let (_, context) = try testBundleAndContext(named: "TestBundle") @@ -414,7 +414,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeExternalNode() throws { let title = "unreferenced-tutorial" - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .external, title: title) let (_, context) = try testBundleAndContext(named: "TestBundle") @@ -433,7 +433,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeFragmentNode() throws { let title = "unreferenced-tutorial" let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. TopicGraph.Node { let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. TopicGraph.Node { let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. RenderNode { let (bundle, context) = try testBundleAndContext(named: testBundleName) - let node = try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return try XCTUnwrap(translator.visit(node.semantic) as? RenderNode) } @@ -273,7 +273,7 @@ extension XCTestCase { context: context, bundle: bundle, identifier: ResolvedTopicReference( - bundleIdentifier: bundle.id.rawValue, + id: bundle.id, path: "/test-path-123", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift index 69759193a..4b8fe0fa2 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift @@ -25,7 +25,7 @@ class ConvertActionIndexerTests: XCTestCase { // Add /documentation/MyKit to the index, verify the tree dump do { - let reference = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let renderNode = try converter.convert(context.entity(with: reference)) let tempIndexURL = try createTemporaryDirectory(named: "index") @@ -47,10 +47,10 @@ class ConvertActionIndexerTests: XCTestCase { // Add two nodes /documentation/MyKit and /documentation/Test-Bundle/Default-Code-Listing-Syntax to the index // and verify the tree. do { - let reference1 = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let renderNode1 = try converter.convert(context.entity(with: reference1)) - let reference2 = ResolvedTopicReference(bundleIdentifier: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", sourceLanguage: .swift) + let reference2 = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", sourceLanguage: .swift) let renderNode2 = try converter.convert(context.entity(with: reference2)) let tempIndexURL = try createTemporaryDirectory(named: "index") diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index 8951e5da0..5c06e70fe 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -1754,7 +1754,7 @@ class ConvertActionTests: XCTestCase { struct TestReferenceResolver: ExternalDocumentationSource { func resolve(_ reference: TopicReference) -> TopicReferenceResolutionResult { - return .success(ResolvedTopicReference(bundleIdentifier: "com.example.test", path: reference.url!.path, sourceLanguage: .swift)) + return .success(ResolvedTopicReference(id: "com.example.test", path: reference.url!.path, sourceLanguage: .swift)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { diff --git a/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift b/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift index 83028182b..b7764cce9 100644 --- a/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift @@ -32,7 +32,7 @@ class JSONEncodingRenderNodeWriterTests: XCTestCase { transformForStaticHostingIndexHTML: indexHTML ) - let renderNode = RenderNode(identifier: .init(bundleIdentifier: "com.test", path: "/documentation/test", sourceLanguage: .swift), kind: .article) + let renderNode = RenderNode(identifier: .init(id: "com.test", path: "/documentation/test", sourceLanguage: .swift), kind: .article) // We take precautions in case we deadlock to stop the execution with a failing code. // In case the original issue is present and we deadlock, we fatalError from a bg thread. diff --git a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift index 96d875eb7..94400fd31 100644 --- a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift @@ -57,7 +57,7 @@ class SemanticAnalyzerTests: XCTestCase { func testDoNotCrashOnInvalidContent() throws { let (bundle, context) = try loadBundle(catalog: catalogHierarchy) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleIdentifier: bundle.id.rawValue, path: "/Oops", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/Oops", sourceLanguage: .swift))) } func testWarningsAboutDirectiveSupport() throws { From 221891ae4397ccf5919322ae01307c82155631da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 16:03:05 +0200 Subject: [PATCH 08/17] Deprecate `BundleIdentifier` in favor of `DocumentationBundle/Identifier` --- .../DocumentationContext+Deprecated.swift | 15 +++++- .../DocumentationContext+Configuration.swift | 2 +- .../Infrastructure/DocumentationContext.swift | 46 +++++++++++++------ .../Infrastructure/DocumentationCurator.swift | 2 +- .../PathHierarchyBasedLinkResolver.swift | 3 +- .../ExternalMarkupReferenceWalker.swift | 6 +-- .../ExternalReferenceWalker.swift | 4 +- .../Actions/Convert/ConvertAction.swift | 6 +-- .../Convert/ConvertFileWritingConsumer.swift | 20 ++++---- .../Benchmark/ExternalTopicsHashTests.swift | 6 +-- .../DocumentationContextTests.swift | 10 ++-- .../ExternalReferenceResolverTests.swift | 24 +++++----- .../XCTestCase+LoadingTestData.swift | 8 ++-- 13 files changed, 89 insertions(+), 63 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/Context/Deprecated/DocumentationContext+Deprecated.swift b/Sources/SwiftDocC/Infrastructure/Context/Deprecated/DocumentationContext+Deprecated.swift index 6e4aadd6b..89202ce26 100644 --- a/Sources/SwiftDocC/Infrastructure/Context/Deprecated/DocumentationContext+Deprecated.swift +++ b/Sources/SwiftDocC/Infrastructure/Context/Deprecated/DocumentationContext+Deprecated.swift @@ -18,8 +18,19 @@ extension DocumentationContext { @available(*, deprecated, renamed: "configuration.externalDocumentationConfiguration.sources", message: "Use 'configuration.externalDocumentationConfiguration.sources' instead. This deprecated API will be removed after Swift 6.2 is released.") public var externalDocumentationSources: [BundleIdentifier: ExternalDocumentationSource] { - get { configuration.externalDocumentationConfiguration.sources } - set { configuration.externalDocumentationConfiguration.sources = newValue } + get { + var result = [BundleIdentifier: ExternalDocumentationSource]() + for (key, value) in configuration.externalDocumentationConfiguration.sources { + result[key.rawValue] = value + } + return result + } + set { + configuration.externalDocumentationConfiguration.sources.removeAll() + for (key, value) in newValue { + configuration.externalDocumentationConfiguration.sources[.init(rawValue: key)] = value + } + } } @available(*, deprecated, renamed: "configuration.externalDocumentationConfiguration.globalSymbolResolver", message: "Use 'configuration.externalDocumentationConfiguration.globalSymbolResolver' instead. This deprecated API will be removed after Swift 6.2 is released.") diff --git a/Sources/SwiftDocC/Infrastructure/Context/DocumentationContext+Configuration.swift b/Sources/SwiftDocC/Infrastructure/Context/DocumentationContext+Configuration.swift index 19fb6a78a..99c941ddb 100644 --- a/Sources/SwiftDocC/Infrastructure/Context/DocumentationContext+Configuration.swift +++ b/Sources/SwiftDocC/Infrastructure/Context/DocumentationContext+Configuration.swift @@ -76,7 +76,7 @@ extension DocumentationContext { /// A collection of configuration related to external sources of documentation. public struct ExternalDocumentationConfiguration { /// The lookup of external documentation sources by their bundle identifiers. - public var sources: [BundleIdentifier: ExternalDocumentationSource] = [:] + public var sources: [DocumentationBundle.Identifier: ExternalDocumentationSource] = [:] /// A type that resolves all symbols that are referenced in symbol graph files but can't be found in any of the locally available symbol graph files. public var globalSymbolResolver: GlobalExternalSymbolResolver? /// A list of URLs to documentation archives that the local documentation depends on. diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index 23c1ecc0a..e1f682d08 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -59,6 +59,7 @@ public protocol DocumentationContextDataProviderDelegate: AnyObject { /// This value is typically a reverse host name, for example: `com..`. /// /// Documentation links may include the bundle identifier---as a host component of the URL---to reference content in a specific documentation bundle. +@available(*, deprecated, renamed: "DocumentationBundle.Identifier", message: "Use 'DocumentationBundle.Identifier' instead. This deprecated API will be removed after 6.2 is released") public typealias BundleIdentifier = String /// The documentation context manages the in-memory model for the built documentation. @@ -354,7 +355,7 @@ public class DocumentationContext { /// - bundle: The bundle that was removed. @available(*, deprecated, message: "Pass the context its inputs at initialization instead. This deprecated API will be removed after 6.2 is released") public func dataProvider(_ dataProvider: DocumentationContextDataProvider, didRemoveBundle bundle: DocumentationBundle) throws { - linkResolver.localResolver?.unregisterBundle(identifier: bundle.identifier) + linkResolver.localResolver?.unregisterBundle(identifier: bundle.id) // Purge the reference cache for this bundle and disable reference caching for // this bundle moving forward. @@ -482,7 +483,7 @@ public class DocumentationContext { /// - Parameters: /// - references: A list of references to local nodes to visit to collect links. /// - localBundleID: The local bundle ID, used to identify and skip absolute fully qualified local links. - private func preResolveExternalLinks(references: [ResolvedTopicReference], localBundleID: BundleIdentifier) { + private func preResolveExternalLinks(references: [ResolvedTopicReference], localBundleID: DocumentationBundle.Identifier) { preResolveExternalLinks(semanticObjects: references.compactMap({ reference -> ReferencedSemanticObject? in guard let node = try? entity(with: reference), let semantic = node.semantic else { return nil } return (reference: reference, semantic: semantic) @@ -504,11 +505,11 @@ public class DocumentationContext { /// - Parameters: /// - semanticObjects: A list of semantic objects to visit to collect links. /// - localBundleID: The local bundle ID, used to identify and skip absolute fully qualified local links. - private func preResolveExternalLinks(semanticObjects: [ReferencedSemanticObject], localBundleID: BundleIdentifier) { + private func preResolveExternalLinks(semanticObjects: [ReferencedSemanticObject], localBundleID: DocumentationBundle.Identifier) { // If there are no external resolvers added we will not resolve any links. guard !configuration.externalDocumentationConfiguration.sources.isEmpty else { return } - let collectedExternalLinks = Synchronized([String: Set]()) + let collectedExternalLinks = Synchronized([DocumentationBundle.Identifier: Set]()) semanticObjects.concurrentPerform { _, semantic in autoreleasepool { // Walk the node and extract external link references. @@ -1407,7 +1408,7 @@ public class DocumentationContext { } // Resolve any external references first - preResolveExternalLinks(references: Array(moduleReferences.values) + combinedSymbols.keys.compactMap({ documentationCache.reference(symbolID: $0) }), localBundleID: bundle.id.rawValue) + preResolveExternalLinks(references: Array(moduleReferences.values) + combinedSymbols.keys.compactMap({ documentationCache.reference(symbolID: $0) }), localBundleID: bundle.id) // Look up and add symbols that are _referenced_ in the symbol graph but don't exist in the symbol graph. try resolveExternalSymbols(in: combinedSymbols, relationships: combinedRelationshipsBySelector) @@ -1798,26 +1799,41 @@ public class DocumentationContext { /// Returns a list of all the image assets that registered for a given `bundleIdentifier`. /// - /// - Parameter bundleIdentifier: The identifier of the bundle to return image assets for. + /// - Parameter id: The identifier of the bundle to return image assets for. /// - Returns: A list of all the image assets for the given bundle. + public func registeredImageAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: id) + } + + @available(*, deprecated, renamed: "registeredImageAssets(for:)", message: "registeredImageAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") public func registeredImageAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) + registeredImageAssets(for: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } /// Returns a list of all the video assets that registered for a given `bundleIdentifier`. /// - /// - Parameter bundleIdentifier: The identifier of the bundle to return video assets for. + /// - Parameter id: The identifier of the bundle to return video assets for. /// - Returns: A list of all the video assets for the given bundle. + public func registeredVideoAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: id) + } + + @available(*, deprecated, renamed: "registeredVideoAssets(for:)", message: "registeredImageAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") public func registeredVideoAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) + registeredVideoAssets(for: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } /// Returns a list of all the download assets that registered for a given `bundleIdentifier`. /// - /// - Parameter bundleIdentifier: The identifier of the bundle to return download assets for. + /// - Parameter id: The identifier of the bundle to return download assets for. /// - Returns: A list of all the download assets for the given bundle. + public func registeredDownloadsAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: id) + } + + @available(*, deprecated, renamed: "registeredDownloadsAssets(for:)", message: "registeredDownloadsAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") public func registeredDownloadsAssets(forBundleID bundleIdentifier: BundleIdentifier) -> [DataAsset] { - return registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) + registeredDownloadsAssets(for: DocumentationBundle.Identifier(rawValue: bundleIdentifier)) } typealias Articles = [DocumentationContext.SemanticResult
] @@ -2316,7 +2332,7 @@ public class DocumentationContext { tutorialTableOfContentsResults.map(referencedSemanticObject) + tutorials.map(referencedSemanticObject) + tutorialArticles.map(referencedSemanticObject), - localBundleID: bundle.id.rawValue) + localBundleID: bundle.id) resolveLinks( tutorialTableOfContents: tutorialTableOfContentsResults, @@ -2358,7 +2374,7 @@ public class DocumentationContext { // Article curation is only done automatically if there is only one root module if let rootNode = rootNodeForAutomaticCuration { let articleReferences = try autoCurateArticles(otherArticles, startingFrom: rootNode) - preResolveExternalLinks(references: articleReferences, localBundleID: bundle.id.rawValue) + preResolveExternalLinks(references: articleReferences, localBundleID: bundle.id) resolveLinks(curatedReferences: Set(articleReferences), bundle: bundle) } @@ -2373,7 +2389,7 @@ public class DocumentationContext { linkResolver.localResolver.addAnchorForSymbols(localCache: documentationCache) // Fifth, resolve links in nodes that are added solely via curation - preResolveExternalLinks(references: Array(allCuratedReferences), localBundleID: bundle.id.rawValue) + preResolveExternalLinks(references: Array(allCuratedReferences), localBundleID: bundle.id) resolveLinks(curatedReferences: allCuratedReferences, bundle: bundle) if configuration.convertServiceConfiguration.fallbackResolver != nil { @@ -2722,7 +2738,7 @@ public class DocumentationContext { } private func externalEntity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity? { - return configuration.externalDocumentationConfiguration.sources[reference.id.rawValue].map({ $0.entity(with: reference) }) + return configuration.externalDocumentationConfiguration.sources[reference.id].map({ $0.entity(with: reference) }) ?? configuration.convertServiceConfiguration.fallbackResolver?.entityIfPreviouslyResolved(with: reference) } diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift index f3b646bcc..80057ce23 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift @@ -80,7 +80,7 @@ struct DocumentationCurator { } // Check if the link has been externally resolved already. - if let bundleID = unresolved.topicURL.components.host, + if let bundleID = unresolved.topicURL.components.host.map({ DocumentationBundle.Identifier(rawValue: $0) }), context.configuration.externalDocumentationConfiguration.sources[bundleID] != nil || context.configuration.convertServiceConfiguration.fallbackResolver != nil { if case .success(let resolvedExternalReference) = context.externallyResolvedLinks[unresolved.topicURL] { return resolvedExternalReference diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift index 29b395e62..ea5e28b83 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift @@ -25,8 +25,7 @@ final class PathHierarchyBasedLinkResolver { } /// Remove all matches from a given documentation bundle from the link resolver. - func unregisterBundle(identifier: BundleIdentifier) { - let identifier = DocumentationBundle.Identifier(rawValue: identifier) + func unregisterBundle(identifier: DocumentationBundle.Identifier) { var newMap = BidirectionalMap() for (id, reference) in resolvedReferenceMap { if reference.id == identifier { diff --git a/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalMarkupReferenceWalker.swift b/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalMarkupReferenceWalker.swift index e62e83952..ebc3406fc 100644 --- a/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalMarkupReferenceWalker.swift +++ b/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalMarkupReferenceWalker.swift @@ -14,10 +14,10 @@ import Markdown /// Walks a markup tree and collects any links external to a given bundle. struct ExternalMarkupReferenceWalker: MarkupVisitor { /// The local bundle ID, used to identify and skip absolute fully qualified local links. - var localBundleID: BundleIdentifier + var localBundleID: DocumentationBundle.Identifier /// After walking a markup tree, all encountered external links are collected grouped by the bundle ID. - var collectedExternalLinks = [BundleIdentifier: Set]() + var collectedExternalLinks = [DocumentationBundle.Identifier: Set]() /// Descends down the given elements' children. mutating func defaultVisit(_ markup: Markup) { @@ -31,7 +31,7 @@ struct ExternalMarkupReferenceWalker: MarkupVisitor { // Only process documentation links to external bundles guard let destination = link.destination, let url = ValidatedURL(parsingAuthoredLink: destination)?.requiring(scheme: ResolvedTopicReference.urlScheme), - let bundleID = url.components.host, + let bundleID = url.components.host.map({ DocumentationBundle.Identifier(rawValue: $0) }), bundleID != localBundleID else { return diff --git a/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalReferenceWalker.swift b/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalReferenceWalker.swift index d042b90bb..2b100183f 100644 --- a/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalReferenceWalker.swift +++ b/Sources/SwiftDocC/Semantics/ExternalLinks/ExternalReferenceWalker.swift @@ -41,7 +41,7 @@ struct ExternalReferenceWalker: SemanticVisitor { private var markupResolver: ExternalMarkupReferenceWalker /// Collected unresolved external references, grouped by the bundle ID. - var collectedExternalReferences: [BundleIdentifier: [UnresolvedTopicReference]] { + var collectedExternalReferences: [DocumentationBundle.Identifier: [UnresolvedTopicReference]] { return markupResolver.collectedExternalLinks.mapValues { links in links.map(UnresolvedTopicReference.init(topicURL:)) } @@ -49,7 +49,7 @@ struct ExternalReferenceWalker: SemanticVisitor { /// Creates a new semantic walker that collects links to other documentation sources. /// - Parameter localBundleID: The local bundle ID, used to identify and skip absolute fully qualified local links. - init(localBundleID: BundleIdentifier) { + init(localBundleID: DocumentationBundle.Identifier) { self.markupResolver = ExternalMarkupReferenceWalker(localBundleID: localBundleID) } diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift index 7e8a3cb7d..09946b3d8 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift @@ -160,7 +160,7 @@ public struct ConvertAction: AsyncAction { } if let outOfProcessResolver { - configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.id.rawValue] = outOfProcessResolver + configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.id] = outOfProcessResolver configuration.externalDocumentationConfiguration.globalSymbolResolver = outOfProcessResolver } configuration.externalDocumentationConfiguration.dependencyArchives = dependencies @@ -288,7 +288,7 @@ public struct ConvertAction: AsyncAction { indexer: indexer, enableCustomTemplates: experimentalEnableCustomTemplates, transformForStaticHostingIndexHTML: transformForStaticHosting ? indexHTML : nil, - bundleIdentifier: bundle.id.rawValue + bundleID: bundle.id ) if experimentalModifyCatalogWithGeneratedCuration, let catalogURL = rootURL { @@ -422,7 +422,7 @@ public struct ConvertAction: AsyncAction { context: context, indexer: nil, transformForStaticHostingIndexHTML: nil, - bundleIdentifier: bundle.id.rawValue + bundleID: bundle.id ) try outputConsumer.consume(benchmarks: Benchmark.main) diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift index 08f857e00..982170b32 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertFileWritingConsumer.swift @@ -34,7 +34,7 @@ struct ConvertFileWritingConsumer: ConvertOutputConsumer { indexer: ConvertAction.Indexer?, enableCustomTemplates: Bool = false, transformForStaticHostingIndexHTML: URL?, - bundleIdentifier: BundleIdentifier? + bundleID: DocumentationBundle.Identifier? ) { self.targetFolder = targetFolder self.bundleRootFolder = bundleRootFolder @@ -47,7 +47,7 @@ struct ConvertFileWritingConsumer: ConvertOutputConsumer { ) self.indexer = indexer self.enableCustomTemplates = enableCustomTemplates - self.assetPrefixComponent = bundleIdentifier?.split(separator: "/").joined(separator: "-") + self.assetPrefixComponent = bundleID?.rawValue.split(separator: "/").joined(separator: "-") } func consume(problems: [Problem]) throws { @@ -79,45 +79,45 @@ struct ConvertFileWritingConsumer: ConvertOutputConsumer { } // TODO: Supporting a single bundle for the moment. - let bundleIdentifier = bundle.id.rawValue - assert(bundleIdentifier == self.assetPrefixComponent, "Unexpectedly encoding assets for a bundle other than the one this output consumer was created for.") + let bundleID = bundle.id + assert(bundleID.rawValue == self.assetPrefixComponent, "Unexpectedly encoding assets for a bundle other than the one this output consumer was created for.") // Create images directory if needed. let imagesDirectory = targetFolder .appendingPathComponent("images", isDirectory: true) - .appendingPathComponent(bundleIdentifier, isDirectory: true) + .appendingPathComponent(bundleID.rawValue, isDirectory: true) if !fileManager.directoryExists(atPath: imagesDirectory.path) { try fileManager.createDirectory(at: imagesDirectory, withIntermediateDirectories: true, attributes: nil) } // Copy all registered images to the output directory. - for imageAsset in context.registeredImageAssets(forBundleID: bundleIdentifier) { + for imageAsset in context.registeredImageAssets(for: bundleID) { try copyAsset(imageAsset, to: imagesDirectory) } // Create videos directory if needed. let videosDirectory = targetFolder .appendingPathComponent("videos", isDirectory: true) - .appendingPathComponent(bundleIdentifier, isDirectory: true) + .appendingPathComponent(bundleID.rawValue, isDirectory: true) if !fileManager.directoryExists(atPath: videosDirectory.path) { try fileManager.createDirectory(at: videosDirectory, withIntermediateDirectories: true, attributes: nil) } // Copy all registered videos to the output directory. - for videoAsset in context.registeredVideoAssets(forBundleID: bundleIdentifier) { + for videoAsset in context.registeredVideoAssets(for: bundleID) { try copyAsset(videoAsset, to: videosDirectory) } // Create downloads directory if needed. let downloadsDirectory = targetFolder .appendingPathComponent(DownloadReference.locationName, isDirectory: true) - .appendingPathComponent(bundleIdentifier, isDirectory: true) + .appendingPathComponent(bundleID.rawValue, isDirectory: true) if !fileManager.directoryExists(atPath: downloadsDirectory.path) { try fileManager.createDirectory(at: downloadsDirectory, withIntermediateDirectories: true, attributes: nil) } // Copy all downloads into the output directory. - for downloadAsset in context.registeredDownloadsAssets(forBundleID: bundleIdentifier) { + for downloadAsset in context.registeredDownloadsAssets(for: bundleID) { try copyAsset(downloadAsset, to: downloadsDirectory) } diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index d0ce1523c..2bcd77861 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -55,7 +55,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -93,7 +93,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in try """ # ``SideKit/SideClass`` @@ -131,7 +131,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { let externalResolver = self.externalResolver // Load a bundle with external links - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 2703d38e5..3d2a45da9 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -517,7 +517,7 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let imagesRegistered = context - .registeredImageAssets(forBundleID: bundle.id.rawValue) + .registeredImageAssets(for: bundle.id) .flatMap { $0.variants.map { $0.value.lastPathComponent } } .sorted() @@ -561,12 +561,12 @@ class DocumentationContextTests: XCTestCase { func testDownloadAssets() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let downloadsBefore = context.registeredDownloadsAssets(forBundleID: bundle.id.rawValue) + let downloadsBefore = context.registeredDownloadsAssets(for: bundle.id) XCTAssertEqual(downloadsBefore.count, 1) XCTAssertEqual(downloadsBefore.first?.variants.values.first?.lastPathComponent, "project.zip") guard var assetOriginal = context - .registeredImageAssets(forBundleID: bundle.id.rawValue) + .registeredImageAssets(for: bundle.id) .first(where: { asset -> Bool in return asset.variants.values.first(where: { url -> Bool in return url.path.contains("intro.png") @@ -581,7 +581,7 @@ class DocumentationContextTests: XCTestCase { context.updateAsset(named: "intro.png", asset: assetOriginal, in: bundle.rootReference) guard let assetUpdated = context - .registeredImageAssets(forBundleID: bundle.id.rawValue) + .registeredImageAssets(for: bundle.id) .first(where: { asset -> Bool in return asset.variants.values.first(where: { url -> Bool in return url.path.contains("intro.png") @@ -595,7 +595,7 @@ class DocumentationContextTests: XCTestCase { XCTAssertEqual(assetUpdated.context, .download) // Verify the asset is accessible in the downloads collection. - var downloadsAfter = context.registeredDownloadsAssets(forBundleID: bundle.id.rawValue) + var downloadsAfter = context.registeredDownloadsAssets(for: bundle.id) XCTAssertEqual(downloadsAfter.count, 2) downloadsAfter.removeAll(where: { $0.variants.values.first?.lastPathComponent == "project.zip" }) XCTAssertEqual(downloadsAfter.count, 1) diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 0efce7d5f..085ef6a25 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -98,7 +98,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext( copying: "TestBundle", - externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] + externalResolvers: [externalResolver.bundleID: externalResolver] ) { url in let sideClassExtension = """ # ``SideKit/SideClass`` @@ -251,7 +251,7 @@ class ExternalReferenceResolverTests: XCTestCase { externalResolver.resolvedEntityTitle = "ClassName" externalResolver.resolvedEntityKind = resolvedEntityKind - let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) + let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) @@ -293,7 +293,7 @@ class ExternalReferenceResolverTests: XCTestCase { .init(kind: .identifier, spelling: "ClassName", preciseIdentifier: nil), ]) - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -349,7 +349,7 @@ class ExternalReferenceResolverTests: XCTestCase { ]) var configuration = DocumentationContext.Configuration() - configuration.externalDocumentationConfiguration.sources = [externalResolver.bundleID.rawValue: externalResolver] + configuration.externalDocumentationConfiguration.sources = [externalResolver.bundleID: externalResolver] let (bundle, context) = try loadBundle(catalog: tempFolder, configuration: configuration) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -385,7 +385,7 @@ class ExternalReferenceResolverTests: XCTestCase { externalResolver.resolvedEntityTitle = "Name of Sample" externalResolver.resolvedEntityKind = .sampleCode - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -473,7 +473,7 @@ class ExternalReferenceResolverTests: XCTestCase { ), ] - let (_, bundle, context) = try testBundleAndContext(copying: "SampleBundle", excludingPaths: ["MySample.md", "MyLocalSample.md"], externalResolvers: [externalResolver.bundleID.rawValue: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "SampleBundle", excludingPaths: ["MySample.md", "MyLocalSample.md"], externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # SomeSample @@ -871,7 +871,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext( copying: "MixedLanguageFramework", - externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] + externalResolvers: [externalResolver.bundleID: externalResolver] ) { url in let mixedLanguageFrameworkExtension = """ # ``MixedLanguageFramework`` @@ -962,7 +962,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") @@ -1018,7 +1018,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1085,7 +1085,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1170,7 +1170,7 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID.rawValue: resolver]) + let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") @@ -1203,7 +1203,7 @@ class ExternalReferenceResolverTests: XCTestCase { let externalResolver = TestExternalReferenceResolver() let (_, bundle, context) = try testBundleAndContext( copying: bundleName, - externalResolvers: [externalResolver.bundleID.rawValue: externalResolver] + externalResolvers: [externalResolver.bundleID: externalResolver] ) { url in try documentationExtension.utf8Content.write( to: url.appendingPathComponent(documentationExtension.name), diff --git a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift index abdeb9745..4f392459e 100644 --- a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift +++ b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift @@ -19,7 +19,7 @@ extension XCTestCase { /// Loads a documentation bundle from the given source URL and creates a documentation context. func loadBundle( from catalogURL: URL, - externalResolvers: [String: ExternalDocumentationSource] = [:], + externalResolvers: [DocumentationBundle.Identifier: ExternalDocumentationSource] = [:], externalSymbolResolver: GlobalExternalSymbolResolver? = nil, fallbackResolver: ConvertServiceFallbackResolver? = nil, diagnosticEngine: DiagnosticEngine = .init(filterLevel: .hint), @@ -69,7 +69,7 @@ extension XCTestCase { func testBundleAndContext( copying name: String, excludingPaths excludedPaths: [String] = [], - externalResolvers: [BundleIdentifier : ExternalDocumentationSource] = [:], + externalResolvers: [DocumentationBundle.Identifier : ExternalDocumentationSource] = [:], externalSymbolResolver: GlobalExternalSymbolResolver? = nil, fallbackResolver: ConvertServiceFallbackResolver? = nil, diagnosticEngine: DiagnosticEngine = .init(filterLevel: .hint), @@ -106,7 +106,7 @@ extension XCTestCase { func testBundleAndContext( named name: String, - externalResolvers: [String: ExternalDocumentationSource] = [:], + externalResolvers: [DocumentationBundle.Identifier: ExternalDocumentationSource] = [:], fallbackResolver: ConvertServiceFallbackResolver? = nil, configuration: DocumentationContext.Configuration = .init() ) throws -> (URL, DocumentationBundle, DocumentationContext) { @@ -114,7 +114,7 @@ extension XCTestCase { return try loadBundle(from: catalogURL, externalResolvers: externalResolvers, fallbackResolver: fallbackResolver, configuration: configuration) } - func testBundleAndContext(named name: String, externalResolvers: [String: ExternalDocumentationSource] = [:]) throws -> (DocumentationBundle, DocumentationContext) { + func testBundleAndContext(named name: String, externalResolvers: [DocumentationBundle.Identifier: ExternalDocumentationSource] = [:]) throws -> (DocumentationBundle, DocumentationContext) { let (_, bundle, context) = try testBundleAndContext(named: name, externalResolvers: externalResolvers) return (bundle, context) } From 890e3236d75c4938fee346e9be26f768906c6786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:01:53 +0200 Subject: [PATCH 09/17] Use new Identifier type in `BuildMetadata` --- .../ConvertActionConverter.swift | 2 +- Sources/SwiftDocC/Model/BuildMetadata.swift | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift index 0164a3095..1f21efb3a 100644 --- a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift +++ b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift @@ -191,7 +191,7 @@ package enum ConvertActionConverter { break } - try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleIdentifier: bundle.id.rawValue)) + try outputConsumer.consume(buildMetadata: BuildMetadata(bundleDisplayName: bundle.displayName, bundleID: bundle.id)) // Log the finalized topic graph checksum. benchmark(add: Benchmark.TopicGraphHash(context: context)) diff --git a/Sources/SwiftDocC/Model/BuildMetadata.swift b/Sources/SwiftDocC/Model/BuildMetadata.swift index ae68cfd4b..abe6e57e0 100644 --- a/Sources/SwiftDocC/Model/BuildMetadata.swift +++ b/Sources/SwiftDocC/Model/BuildMetadata.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -23,16 +23,29 @@ public struct BuildMetadata: Codable { /// The display name of the documentation bundle that DocC built. public var bundleDisplayName: String + @available(*, deprecated, renamed: "bundleID", message: "Use 'bundleID' instead. This deprecated API will be removed after 6.2 is released") + public var bundleIdentifier: String { + bundleID.rawValue + } + /// The bundle identifier of the documentation bundle that DocC built. - public var bundleIdentifier: String + public let bundleID: DocumentationBundle.Identifier /// Creates a build metadata value for a documentation bundle built by DocC. /// /// - Parameters: /// - bundleDisplayName: The display name of the documentation bundle. - /// - bundleIdentifier: The bundle identifier of the documentation bundle. - public init(bundleDisplayName: String, bundleIdentifier: String) { + /// - bundleID: The bundle identifier of the documentation bundle. + public init(bundleDisplayName: String, bundleID: DocumentationBundle.Identifier) { self.bundleDisplayName = bundleDisplayName - self.bundleIdentifier = bundleIdentifier + self.bundleID = bundleID + } + + @available(*, deprecated, renamed: "init(bundleDisplayName:bundleID:)", message: "Use 'init(bundleDisplayName:bundleID:)' instead. This deprecated API will be removed after 6.2 is released") + public init(bundleDisplayName: String, bundleIdentifier: String) { + self.init( + bundleDisplayName: bundleDisplayName, + bundleID: .init(rawValue: bundleIdentifier) + ) } } From 3c56a2d2f67b83af62e04a93ffc31835e5461add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:02:29 +0200 Subject: [PATCH 10/17] Use new Identifier type in `AssetReference` --- .../Bundle Assets/DataAssetManager.swift | 18 +++++++++++++++--- .../OutOfProcessReferenceResolver.swift | 6 +++--- .../Model/Rendering/RenderContext.swift | 2 +- .../Model/Rendering/RenderNodeTranslator.swift | 2 +- .../Model/Rendering/RenderReferenceStore.swift | 7 ++++++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift b/Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift index 6d78864fc..9e7242524 100644 --- a/Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift +++ b/Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift @@ -346,12 +346,24 @@ fileprivate extension NSRegularExpression { public struct AssetReference: Hashable, Codable { /// The name of the asset. public var assetName: String + @available(*, deprecated, renamed: "bundleID", message: "Use 'bundleID' instead. This deprecated API will be removed after 6.2 is released") + public var bundleIdentifier: String { + bundleID.rawValue + } + /// The identifier of the bundle the asset is apart of. - public var bundleIdentifier: String + public let bundleID: DocumentationBundle.Identifier /// Creates a reference from a given asset name and the bundle it is apart of. - public init(assetName: String, bundleIdentifier: String) { + public init(assetName: String, bundleID: DocumentationBundle.Identifier) { self.assetName = assetName - self.bundleIdentifier = bundleIdentifier + self.bundleID = bundleID + } + @available(*, deprecated, renamed: "init(assetName:bundleID:)", message: "Use 'init(assetName:bundleID:)' instead. This deprecated API will be removed after 6.2 is released") + public init(assetName: String, bundleIdentifier: String) { + self.init( + assetName: assetName, + bundleID: .init(rawValue: bundleIdentifier) + ) } } diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index e504b9a13..c82cce18c 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -497,7 +497,7 @@ extension OutOfProcessReferenceResolver { case .symbol(let identifier): return "symbol: \(identifier.singleQuoted)" case .asset(let asset): - return "asset with name: \(asset.assetName), bundle identifier: \(asset.bundleIdentifier)" + return "asset with name: \(asset.assetName), bundle identifier: \(asset.bundleID)" } } } @@ -779,13 +779,13 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { } func resolveInformationForAsset(named assetName: String) throws -> DataAsset { - let assetReference = AssetReference(assetName: assetName, bundleIdentifier: id.rawValue) + let assetReference = AssetReference(assetName: assetName, bundleID: id) if let asset = assetCache[assetReference] { return asset } let response = try externalLinkResolvingClient.sendAndWait( - request: Request.asset(AssetReference(assetName: assetName, bundleIdentifier: id.rawValue)) + request: Request.asset(AssetReference(assetName: assetName, bundleID: id)) ) as Response switch response { diff --git a/Sources/SwiftDocC/Model/Rendering/RenderContext.swift b/Sources/SwiftDocC/Model/Rendering/RenderContext.swift index 76c8b2802..835227474 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderContext.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderContext.swift @@ -84,7 +84,7 @@ public struct RenderContext { let (bundleID, assetManager) = element for (name, asset) in assetManager.storage { - storage[AssetReference(assetName: name, bundleIdentifier: bundleID.rawValue)] = asset + storage[AssetReference(assetName: name, bundleID: bundleID)] = asset } } diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index 52f2e22b3..dd11083d1 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -1717,7 +1717,7 @@ public struct RenderNodeTranslator: SemanticVisitor { } let media = ResourceReference(bundleIdentifier: oldMedia.bundleIdentifier, path: mediaIdentifier) - guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleIdentifier: identifier.id.rawValue) + guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleID: identifier.id) ?? context.resolveAsset(named: media.path, in: identifier) else { return nil diff --git a/Sources/SwiftDocC/Model/Rendering/RenderReferenceStore.swift b/Sources/SwiftDocC/Model/Rendering/RenderReferenceStore.swift index 6df5e60d3..6937b79e2 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderReferenceStore.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderReferenceStore.swift @@ -38,8 +38,13 @@ public struct RenderReferenceStore: Codable { } /// Returns asset information for the given asset name. + public func content(forAssetNamed assetName: String, bundleID: DocumentationBundle.Identifier) -> DataAsset? { + assets[AssetReference(assetName: assetName, bundleID: bundleID)] + } + + @available(*, deprecated, renamed: "content(forAssetNamed:bundleID:)", message: "Use 'content(forAssetNamed:bundleID:)' instead. This deprecated API will be removed after 6.2 is released") public func content(forAssetNamed assetName: String, bundleIdentifier: String) -> DataAsset? { - assets[AssetReference(assetName: assetName, bundleIdentifier: bundleIdentifier)] + content(forAssetNamed: assetName, bundleID: .init(rawValue: bundleIdentifier)) } } From 13b11fba7051fa8129fe5b679d815a9103789d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:25:44 +0200 Subject: [PATCH 11/17] Use new Identifier type in `ResourceReference` --- .../Infrastructure/DocumentationContext.swift | 4 +-- Sources/SwiftDocC/Model/Identifier.swift | 27 +++++++++---------- .../Rendering/RenderNodeTranslator.swift | 4 +-- .../Semantics/Media/ImageMedia.swift | 2 +- .../Semantics/Media/VideoMedia.swift | 4 +-- .../Semantics/Metadata/CallToAction.swift | 4 +-- .../Semantics/Metadata/PageImage.swift | 2 +- .../Semantics/ReferenceResolver.swift | 4 +-- .../Semantics/Tutorial/Tasks/Steps/Code.swift | 4 +-- .../Semantics/Tutorial/Tutorial.swift | 2 +- .../ConvertService/ConvertServiceTests.swift | 6 ++--- .../DocumentationContextTests.swift | 16 +++++------ .../Model/LineHighlighterTests.swift | 22 +++++++-------- .../Semantics/ChoiceTests.swift | 2 +- .../Semantics/MultipleChoiceTests.swift | 2 +- .../Semantics/TutorialArticleTests.swift | 18 ++++++------- .../Semantics/TutorialTests.swift | 14 +++++----- .../ConvertActionTests.swift | 2 +- .../MergeActionTests.swift | 2 +- 19 files changed, 70 insertions(+), 71 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index e1f682d08..a164fa452 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -2710,7 +2710,7 @@ public class DocumentationContext { */ public func resource(with identifier: ResourceReference, trait: DataTraitCollection = .init()) throws -> Data { guard let bundle, - let assetManager = assetManagers[DocumentationBundle.Identifier(rawValue: identifier.bundleIdentifier)], + let assetManager = assetManagers[identifier.bundleID], let asset = assetManager.allData(named: identifier.path) else { throw ContextError.notFound(identifier.url) } @@ -2722,7 +2722,7 @@ public class DocumentationContext { /// Returns true if a resource with the given identifier exists in the registered bundle. public func resourceExists(with identifier: ResourceReference, ofType expectedAssetType: AssetType? = nil) -> Bool { - guard let assetManager = assetManagers[DocumentationBundle.Identifier(rawValue: identifier.bundleIdentifier)] else { + guard let assetManager = assetManagers[identifier.bundleID] else { return false } diff --git a/Sources/SwiftDocC/Model/Identifier.swift b/Sources/SwiftDocC/Model/Identifier.swift index 557637f0c..9b093e0fa 100644 --- a/Sources/SwiftDocC/Model/Identifier.swift +++ b/Sources/SwiftDocC/Model/Identifier.swift @@ -592,26 +592,25 @@ public struct UnresolvedTopicReference: Hashable, CustomStringConvertible { } } -/** - A reference to an auxiliary resource such as an image. - */ +/// A reference to an auxiliary resource such as an image. public struct ResourceReference: Hashable { - /** - The documentation bundle identifier for the bundle in which this resource resides. - */ - public let bundleIdentifier: String + @available(*, deprecated, renamed: "bundleID", message: "Use 'bundleID' instead. This deprecated API will be removed after 6.2 is released") + public var bundleIdentifier: String { + bundleID.rawValue + } + + /// The documentation bundle identifier for the bundle in which this resource resides. + public let bundleID: DocumentationBundle.Identifier - /** - The path of the resource local to its bundle. - */ + /// The path of the resource local to its bundle. public let path: String /// Creates a new resource reference. /// - Parameters: - /// - bundleIdentifier: The documentation bundle identifier for the bundle in which this resource resides. + /// - bundleID: The documentation bundle identifier for the bundle in which this resource resides. /// - path: The path of the resource local to its bundle. - init(bundleIdentifier: String, path: String) { - self.bundleIdentifier = bundleIdentifier + init(bundleID: DocumentationBundle.Identifier, path: String) { + self.bundleID = bundleID self.path = path.removingPercentEncoding ?? path } @@ -619,7 +618,7 @@ public struct ResourceReference: Hashable { var url: URL { var components = URLComponents() components.scheme = ResolvedTopicReference.urlScheme - components.host = bundleIdentifier + components.host = bundleID.rawValue components.path = "/" + path return components.url! } diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index dd11083d1..de3a4492f 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -56,7 +56,7 @@ public struct RenderNodeTranslator: SemanticVisitor { return nil } - let fileReference = ResourceReference(bundleIdentifier: code.fileReference.bundleIdentifier, path: fileIdentifier) + let fileReference = ResourceReference(bundleID: code.fileReference.bundleID, path: fileIdentifier) guard let fileContents = fileContents(with: fileReference) else { return nil } @@ -1716,7 +1716,7 @@ public struct RenderNodeTranslator: SemanticVisitor { return nil } - let media = ResourceReference(bundleIdentifier: oldMedia.bundleIdentifier, path: mediaIdentifier) + let media = ResourceReference(bundleID: oldMedia.bundleID, path: mediaIdentifier) guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleID: identifier.id) ?? context.resolveAsset(named: media.path, in: identifier) else { diff --git a/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift b/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift index a6e97df00..7f583f1d3 100644 --- a/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift +++ b/Sources/SwiftDocC/Semantics/Media/ImageMedia.swift @@ -19,7 +19,7 @@ public final class ImageMedia: Semantic, Media, AutomaticDirectiveConvertible { @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public private(set) var source: ResourceReference diff --git a/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift b/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift index 66a40e44c..03286a31b 100644 --- a/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift +++ b/Sources/SwiftDocC/Semantics/Media/VideoMedia.swift @@ -21,7 +21,7 @@ public final class VideoMedia: Semantic, Media, AutomaticDirectiveConvertible { @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public private(set) var source: ResourceReference @@ -44,7 +44,7 @@ public final class VideoMedia: Semantic, Media, AutomaticDirectiveConvertible { /// An image to be shown when the video isn't playing. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public private(set) var poster: ResourceReference? = nil diff --git a/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift b/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift index bc2fa520f..7cd25a29f 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/CallToAction.swift @@ -60,7 +60,7 @@ public final class CallToAction: Semantic, AutomaticDirectiveConvertible { /// The location of the associated link, as a reference to a file in this documentation bundle. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public var file: ResourceReference? = nil @@ -173,7 +173,7 @@ extension CallToAction { ] )) } else { - self.file = ResourceReference(bundleIdentifier: file.bundleIdentifier, path: file.url.lastPathComponent) + self.file = ResourceReference(bundleID: file.bundleID, path: file.url.lastPathComponent) } } diff --git a/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift b/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift index d3ef43c86..7b6eccb93 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/PageImage.swift @@ -28,7 +28,7 @@ public final class PageImage: Semantic, AutomaticDirectiveConvertible { /// The base file name of an image in your documentation catalog. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public private(set) var source: ResourceReference diff --git a/Sources/SwiftDocC/Semantics/ReferenceResolver.swift b/Sources/SwiftDocC/Semantics/ReferenceResolver.swift index 9da23a192..8d0c3c243 100644 --- a/Sources/SwiftDocC/Semantics/ReferenceResolver.swift +++ b/Sources/SwiftDocC/Semantics/ReferenceResolver.swift @@ -544,13 +544,13 @@ fileprivate extension URL { extension Image { func reference(in bundle: DocumentationBundle) -> ResourceReference? { guard let source else { - return ResourceReference(bundleIdentifier: bundle.id.rawValue, path: "") + return ResourceReference(bundleID: bundle.id, path: "") } if let url = URL(string: source), url.isLikelyWebURL { return nil } else { - return ResourceReference(bundleIdentifier: bundle.id.rawValue, path: source) + return ResourceReference(bundleID: bundle.id, path: source) } } } diff --git a/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift b/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift index b2a577b50..d49b6b173 100644 --- a/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift +++ b/Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Code.swift @@ -67,7 +67,7 @@ public final class Code: Semantic, DirectiveConvertible { Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .warning, allowedDirectives: [ImageMedia.directiveName, VideoMedia.directiveName]).analyze(directive, children: directive.children, source: source, for: bundle, in: context, problems: &problems) guard let requiredFileReference = Semantic.Analyses.HasArgument(severityIfNotFound: .warning).analyze(directive, arguments: arguments, problems: &problems) else { return nil } - let fileReference = ResourceReference(bundleIdentifier: bundle.id.rawValue, path: requiredFileReference) + let fileReference = ResourceReference(bundleID: bundle.id, path: requiredFileReference) guard let requiredFileName = Semantic.Analyses.HasArgument(severityIfNotFound: .warning).analyze(directive, arguments: arguments, problems: &problems) else { return nil } @@ -83,7 +83,7 @@ public final class Code: Semantic, DirectiveConvertible { let (optionalPreview, _) = Semantic.Analyses.HasExactlyOneImageOrVideoMedia(severityIfNotFound: nil).analyze(directive, children: directive.children, source: source, for: bundle, in: context, problems: &problems) let optionalPreviousFileReference = Semantic.Analyses.HasArgument(severityIfNotFound: nil).analyze(directive, arguments: arguments, problems: &problems).map { argument in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argument) + ResourceReference(bundleID: bundle.id, path: argument) } self.init(originalMarkup: directive, fileReference: fileReference, fileName: requiredFileName, previousFileReference: optionalPreviousFileReference, shouldResetDiff: shouldResetDiff, preview: optionalPreview) diff --git a/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift b/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift index 72dad4fa1..8387152d1 100644 --- a/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift +++ b/Sources/SwiftDocC/Semantics/Tutorial/Tutorial.swift @@ -23,7 +23,7 @@ public final class Tutorial: Semantic, AutomaticDirectiveConvertible, Abstracted /// Project files to download to get started with the ``Tutorial``. @DirectiveArgumentWrapped( parseArgument: { bundle, argumentValue in - ResourceReference(bundleIdentifier: bundle.id.rawValue, path: argumentValue) + ResourceReference(bundleID: bundle.id, path: argumentValue) } ) public private(set) var projectFiles: ResourceReference? = nil diff --git a/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift b/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift index 2d9e7b3b5..3f54e6512 100644 --- a/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift +++ b/Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift @@ -918,7 +918,7 @@ class ConvertServiceTests: XCTestCase { ) case .asset(let assetReference): - switch (assetReference.assetName, assetReference.bundleIdentifier) { + switch (assetReference.assetName, assetReference.bundleID) { case (let assetName, "identifier") where ["before.swift", "after.swift"].contains(assetName): var asset = DataAsset() asset.register( @@ -1089,7 +1089,7 @@ class ConvertServiceTests: XCTestCase { return nil case .asset(let assetReference): - switch (assetReference.assetName, assetReference.bundleIdentifier) { + switch (assetReference.assetName, assetReference.bundleID) { case (let assetName, "identifier") where expectedAssetNames.contains(assetName): var asset = DataAsset() asset.register( @@ -1881,7 +1881,7 @@ class ConvertServiceTests: XCTestCase { } case .asset(let assetReference): - switch (assetReference.assetName, assetReference.bundleIdentifier) { + switch (assetReference.assetName, assetReference.bundleID) { case ("image.png", "com.test.bundle"): var asset = DataAsset() asset.register( diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 3d2a45da9..811d63ddf 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -418,15 +418,15 @@ class DocumentationContextTests: XCTestCase { func testThrowsErrorForMissingResource() throws { let (_, context) = try testBundleAndContext() - XCTAssertThrowsError(try context.resource(with: ResourceReference(bundleIdentifier: "com.example.missing", path: "/missing.swift")), "Expected requesting an unknown file to result in an error.") + XCTAssertThrowsError(try context.resource(with: ResourceReference(bundleID: "com.example.missing", path: "/missing.swift")), "Expected requesting an unknown file to result in an error.") } func testThrowsErrorForQualifiedImagePaths() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let id = bundle.id.rawValue + let id = bundle.id - let figure = ResourceReference(bundleIdentifier: id, path: "figure1.jpg") - let imageFigure = ResourceReference(bundleIdentifier: id, path: "images/figure1.jpg") + let figure = ResourceReference(bundleID: id, path: "figure1.jpg") + let imageFigure = ResourceReference(bundleID: id, path: "images/figure1.jpg") XCTAssertNoThrow(try context.resource(with: figure), "\(figure.path) expected in \(bundle.displayName)") XCTAssertThrowsError(try context.resource(with: imageFigure), "Images should be registered (and referred to) by their name, not by their path.") @@ -436,11 +436,11 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let existingImageReference = ResourceReference( - bundleIdentifier: bundle.id.rawValue, + bundleID: bundle.id, path: "introposter" ) let nonexistentImageReference = ResourceReference( - bundleIdentifier: bundle.id.rawValue, + bundleID: bundle.id, path: "nonexistent-image" ) XCTAssertTrue( @@ -453,11 +453,11 @@ class DocumentationContextTests: XCTestCase { ) let correctImageReference = ResourceReference( - bundleIdentifier: bundle.id.rawValue, + bundleID: bundle.id, path: "figure1.jpg" ) let incorrectImageReference = ResourceReference( - bundleIdentifier: bundle.id.rawValue, + bundleID: bundle.id, path: "images/figure1.jpg" ) XCTAssertTrue( diff --git a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift index 4c1e38a90..28369bebf 100644 --- a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift +++ b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift @@ -14,7 +14,7 @@ import Markdown import SwiftDocCTestUtilities class LineHighlighterTests: XCTestCase { - static let bundleIdentifier = "org.swift.docc.LineHighlighterTests" + static let bundleID: DocumentationBundle.Identifier = "org.swift.docc.LineHighlighterTests" static let defaultOverview = TextFile(name: "TechnologyX.tutorial", utf8Content: """ @Technology(name: "TechnologyX") { @Intro(title: "Technology X") { @@ -42,7 +42,7 @@ class LineHighlighterTests: XCTestCase { codeFiles: [TextFile] ) -> Folder { Folder(name: "unit-test.docc", content: [ - InfoPlist(displayName: "Line Highlighter Tests", identifier: bundleIdentifier), + InfoPlist(displayName: "Line Highlighter Tests", identifier: bundleID.rawValue), Folder(name: "Resources", content: [overview, tutorial] + codeFiles), ]) } @@ -95,7 +95,7 @@ class LineHighlighterTests: XCTestCase { let results = try highlights(tutorialFile: tutorialFile, codeFiles: [code1]) XCTAssertEqual(1, results.count) results.first.map { result in - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code1.name), result.file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code1.name), result.file) XCTAssertTrue(result.highlights.isEmpty) } } @@ -124,7 +124,7 @@ class LineHighlighterTests: XCTestCase { let results = try highlights(tutorialFile: tutorialFile, codeFiles: [code0, code1]) XCTAssertEqual(1, results.count) results.first.map { result in - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code1.name), result.file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code1.name), result.file) XCTAssertEqual(1, result.highlights.count) result.highlights.first.map { highlight in XCTAssertEqual(2, highlight.line) @@ -163,10 +163,10 @@ class LineHighlighterTests: XCTestCase { let results = try highlights(tutorialFile: tutorialFile, codeFiles: [code1, code2]) XCTAssertEqual(2, results.count) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code1.name), results[0].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code1.name), results[0].file) XCTAssertTrue(results[0].highlights.isEmpty) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code2.name), results[1].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code2.name), results[1].file) XCTAssertTrue(results[1].highlights.isEmpty) } @@ -193,7 +193,7 @@ class LineHighlighterTests: XCTestCase { let results = try highlights(tutorialFile: tutorialFile, codeFiles: [code0, code1]) XCTAssertEqual(1, results.count) results.first.map { result in - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code1.name), result.file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code1.name), result.file) XCTAssertTrue(result.highlights.isEmpty) } } @@ -226,10 +226,10 @@ class LineHighlighterTests: XCTestCase { XCTAssertEqual(2, results.count) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code1.name), results[0].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code1.name), results[0].file) XCTAssertTrue(results[0].highlights.isEmpty) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code2.name), results[1].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code2.name), results[1].file) XCTAssertTrue(results[1].highlights.isEmpty) } @@ -265,10 +265,10 @@ class LineHighlighterTests: XCTestCase { XCTAssertEqual(2, results.count) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code0.name), results[0].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code0.name), results[0].file) XCTAssertTrue(results[0].highlights.isEmpty) - XCTAssertEqual(ResourceReference(bundleIdentifier: LineHighlighterTests.bundleIdentifier, path: code2.name), results[1].file) + XCTAssertEqual(ResourceReference(bundleID: LineHighlighterTests.bundleID, path: code2.name), results[1].file) XCTAssertEqual(1, results[1].highlights.count) results[1].highlights.first.map { highlight in XCTAssertEqual(2, highlight.line) diff --git a/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift b/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift index 6dc99e6a1..28a70df64 100644 --- a/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift @@ -233,7 +233,7 @@ Choice @1:1-9:2 isCorrect: true let expectedDump = """ Choice @1:1-7:2 isCorrect: true ├─ MarkupContainer (empty) -├─ ImageMedia @2:4-2:39 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "blah.png")' altText: 'blah' +├─ ImageMedia @2:4-2:39 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "blah.png")' altText: 'blah' └─ Justification @4:4-6:5 └─ MarkupContainer (1 element) """ diff --git a/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift b/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift index 7d6316d24..1bdc99871 100644 --- a/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift +++ b/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift @@ -117,7 +117,7 @@ class MultipleChoiceTests: XCTestCase { let expectedDump = """ MultipleChoice @1:1-24:2 title: 'SwiftDocC.MarkupContainer' ├─ MarkupContainer (2 elements) -├─ ImageMedia @10:3-10:38 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "blah.png")' altText: 'blah' +├─ ImageMedia @10:3-10:38 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "blah.png")' altText: 'blah' ├─ Choice @12:3-17:5 isCorrect: true │ ├─ MarkupContainer (1 element) │ └─ Justification @14:6-16:7 diff --git a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift index 5518df0e1..d0209fe17 100644 --- a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift @@ -168,7 +168,7 @@ TutorialArticle @1:1-23:2 TutorialArticle @1:1-23:2 title: 'Basic Augmented Reality App' time: '20' ├─ Intro @3:4-10:5 title: 'Basic Augmented Reality App' │ ├─ MarkupContainer (2 elements) -│ └─ ImageMedia @9:7-9:46 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "myimage.png")' altText: 'image' +│ └─ ImageMedia @9:7-9:46 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "myimage.png")' altText: 'image' └─ MarkupContainer (6 elements) """ XCTAssertEqual(expectedDump, article.dump()) @@ -282,29 +282,29 @@ TutorialArticle @1:1-23:2 title: 'Basic Augmented Reality App' time: '20' TutorialArticle @1:1-81:2 ├─ ContentAndMedia @3:4-12:5 mediaPosition: 'leading' │ ├─ MarkupContainer (2 elements) -│ └─ ImageMedia @4:7-4:58 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "customize-text-view.png")' altText: 'alt' +│ └─ ImageMedia @4:7-4:58 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "customize-text-view.png")' altText: 'alt' ├─ ContentAndMedia @14:4-23:5 mediaPosition: 'trailing' │ ├─ MarkupContainer (2 elements) -│ └─ ImageMedia @22:7-22:58 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "customize-text-view.png")' altText: 'alt' +│ └─ ImageMedia @22:7-22:58 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "customize-text-view.png")' altText: 'alt' ├─ MarkupContainer (1 element) ├─ Stack @27:4-51:5 │ ├─ ContentAndMedia @28:7-37:8 mediaPosition: 'trailing' │ │ ├─ MarkupContainer (2 elements) -│ │ └─ ImageMedia @32:10-32:64 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "this-is-still-trailing.png")' altText: 'alt' +│ │ └─ ImageMedia @32:10-32:64 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "this-is-still-trailing.png")' altText: 'alt' │ └─ ContentAndMedia @41:7-50:8 mediaPosition: 'trailing' │ ├─ MarkupContainer (2 elements) -│ └─ ImageMedia @49:10-49:58 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "this-is-trailing.png")' altText: 'alt' +│ └─ ImageMedia @49:10-49:58 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "this-is-trailing.png")' altText: 'alt' ├─ MarkupContainer (3 elements) └─ Stack @61:4-80:5 ├─ ContentAndMedia @62:7-71:8 mediaPosition: 'trailing' │ ├─ MarkupContainer (2 elements) - │ └─ ImageMedia @66:10-66:64 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "this-is-still-trailing.png")' altText: 'alt' + │ └─ ImageMedia @66:10-66:64 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "this-is-still-trailing.png")' altText: 'alt' ├─ ContentAndMedia @73:7-75:8 mediaPosition: 'leading' │ ├─ MarkupContainer (empty) - │ └─ ImageMedia @74:10-74:57 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "this-is-leading.png")' altText: 'alt' + │ └─ ImageMedia @74:10-74:57 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "this-is-leading.png")' altText: 'alt' └─ ContentAndMedia @77:7-79:8 mediaPosition: 'leading' ├─ MarkupContainer (empty) - └─ ImageMedia @78:10-78:57 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "this-is-leading.png")' altText: 'alt' + └─ ImageMedia @78:10-78:57 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "this-is-leading.png")' altText: 'alt' """ XCTAssertEqual(expectedDump, article.dump()) } @@ -374,7 +374,7 @@ TutorialArticle @1:1-81:2 TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' ├─ Intro @2:4-7:5 title: 'Basic Augmented Reality App' │ ├─ MarkupContainer (1 element) -│ └─ ImageMedia @6:7-6:46 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "myimage.png")' altText: 'image' +│ └─ ImageMedia @6:7-6:46 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "myimage.png")' altText: 'image' ├─ MarkupContainer (6 elements) └─ Assessments @21:4-41:5 └─ MultipleChoice @22:7-40:8 title: 'SwiftDocC.MarkupContainer' diff --git a/Tests/SwiftDocCTests/Semantics/TutorialTests.swift b/Tests/SwiftDocCTests/Semantics/TutorialTests.swift index dbfab7792..ef3350884 100644 --- a/Tests/SwiftDocCTests/Semantics/TutorialTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TutorialTests.swift @@ -208,32 +208,32 @@ class TutorialTests: XCTestCase { Tutorial @1:1-150:2 projectFiles: nil ├─ Intro @3:4-6:5 title: 'Basic Augmented Reality App' │ ├─ MarkupContainer (empty) -│ ├─ ImageMedia @5:7-5:46 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "myimage.png")' altText: 'image' -│ └─ VideoMedia @4:7-4:51 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "test.mp4")' poster: 'Optional(SwiftDocC.ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "poster.png"))' +│ ├─ ImageMedia @5:7-5:46 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "myimage.png")' altText: 'image' +│ └─ VideoMedia @4:7-4:51 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "test.mp4")' poster: 'Optional(SwiftDocC.ResourceReference(bundleID: org.swift.docc.example, path: "poster.png"))' ├─ XcodeRequirement @2:4-2:97 title: 'Xcode X.Y Beta Z' destination: 'https://www.example.com/download' ├─ TutorialSection @8:4-48:5 │ ├─ ContentAndMedia @9:7-19:8 mediaPosition: 'trailing' │ │ ├─ MarkupContainer (3 elements) -│ │ └─ ImageMedia @14:10-14:51 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "figure1.png")' altText: 'figure1' +│ │ └─ ImageMedia @14:10-14:51 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "figure1.png")' altText: 'figure1' │ └─ Steps @21:7-47:8 │ ├─ MarkupContainer (1 element) │ ├─ Step @25:10-31:11 │ │ ├─ MarkupContainer (1 element) │ │ ├─ MarkupContainer (empty) -│ │ └─ Code @28:13-30:14 fileReference: ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "code1.swift") fileName: 'MyCode.swift' shouldResetDiff: false preview: Optional(SwiftDocC.ImageMedia) +│ │ └─ Code @28:13-30:14 fileReference: ResourceReference(bundleID: org.swift.docc.example, path: "code1.swift") fileName: 'MyCode.swift' shouldResetDiff: false preview: Optional(SwiftDocC.ImageMedia) │ ├─ Step @32:10-38:11 │ │ ├─ MarkupContainer (1 element) │ │ ├─ MarkupContainer (empty) -│ │ └─ Code @35:13-37:14 fileReference: ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "code2.swift") fileName: 'MyCode.swift' shouldResetDiff: true preview: Optional(SwiftDocC.ImageMedia) +│ │ └─ Code @35:13-37:14 fileReference: ResourceReference(bundleID: org.swift.docc.example, path: "code2.swift") fileName: 'MyCode.swift' shouldResetDiff: true preview: Optional(SwiftDocC.ImageMedia) │ ├─ MarkupContainer (1 element) │ └─ Step @42:10-46:11 │ ├─ MarkupContainer (1 element) │ ├─ MarkupContainer (empty) -│ └─ Code @45:13-45:65 fileReference: ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "othercode1.swift") fileName: 'OtherCode.swift' shouldResetDiff: false preview: nil +│ └─ Code @45:13-45:65 fileReference: ResourceReference(bundleID: org.swift.docc.example, path: "othercode1.swift") fileName: 'OtherCode.swift' shouldResetDiff: false preview: nil ├─ TutorialSection @50:4-77:5 │ ├─ ContentAndMedia @51:7-58:8 mediaPosition: 'trailing' │ │ ├─ MarkupContainer (2 elements) -│ │ └─ ImageMedia @57:10-57:47 source: 'ResourceReference(bundleIdentifier: "org.swift.docc.example", path: "xcode.png")' altText: 'xcode' +│ │ └─ ImageMedia @57:10-57:47 source: 'ResourceReference(bundleID: org.swift.docc.example, path: "xcode.png")' altText: 'xcode' │ └─ Steps @60:7-76:8 │ ├─ MarkupContainer (1 element) │ ├─ Step @64:10-67:11 diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index 5c06e70fe..9a96d31d2 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -2441,7 +2441,7 @@ class ConvertActionTests: XCTestCase { let expectedOutput = Folder(name: ".docc-build", content: [ JSONFile( name: "metadata.json", - content: BuildMetadata(bundleDisplayName: "TestBundle", bundleIdentifier: "com.test.example") + content: BuildMetadata(bundleDisplayName: "TestBundle", bundleID: "com.test.example") ), ]) diff --git a/Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift b/Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift index 1938cf34c..bb1efd559 100644 --- a/Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift @@ -1059,7 +1059,7 @@ class MergeActionTests: XCTestCase { JSONFile(name: "index.json", content: RenderIndex(interfaceLanguages: [:], includedArchiveIdentifiers: [identifier])) ]), - JSONFile(name: "metadata.json", content: BuildMetadata(bundleDisplayName: name, bundleIdentifier: identifier)) + JSONFile(name: "metadata.json", content: BuildMetadata(bundleDisplayName: name, bundleID: DocumentationBundle.Identifier(rawValue: identifier))) ] return Folder(name: "\(name).doccarchive", content: content) From 414ef9c234b9b45459a283ace5a58cf523de2601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:29:16 +0200 Subject: [PATCH 12/17] Use new Identifier type in `ConvertServiceFallbackResolver` --- .../ConvertServiceFallbackResolver.swift | 2 +- .../External Data/OutOfProcessReferenceResolver.swift | 4 ++++ .../Infrastructure/Link Resolution/LinkResolver.swift | 6 +++--- .../ExternalReferenceResolverTests.swift | 10 +++++----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/Fallback Link Resolution/ConvertServiceFallbackResolver.swift b/Sources/SwiftDocC/DocumentationService/Convert/Fallback Link Resolution/ConvertServiceFallbackResolver.swift index f7ab0cd72..8ee83c262 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/Fallback Link Resolution/ConvertServiceFallbackResolver.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/Fallback Link Resolution/ConvertServiceFallbackResolver.swift @@ -26,7 +26,7 @@ protocol ConvertServiceFallbackResolver { /// The bundle identifier for the fallback resolver. /// /// The fallback resolver will only resolve links with this bundle identifier. - var bundleIdentifier: String { get } + var bundleID: DocumentationBundle.Identifier { get } // MARK: References diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index c82cce18c..d57970308 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -798,4 +798,8 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { throw Error.unexpectedResponse(response: response, requestDescription: "asset") } } + + var bundleID: DocumentationBundle.Identifier { + id + } } diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index 552205e55..204544ef9 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -172,8 +172,8 @@ private final class FallbackResolverBasedLinkResolver { let referenceID = unresolvedReference.id ?? parent.id guard let fallbackResolver = context.configuration.convertServiceConfiguration.fallbackResolver, // This uses an underscored internal variant of `registeredBundles` to avoid deprecation warnings and remain compatible with legacy data providers. - let knownBundleIdentifier = context._registeredBundles.first(where: { $0.id == referenceID || urlReadablePath($0.displayName) == referenceID.rawValue })?.id.rawValue, - fallbackResolver.bundleIdentifier == knownBundleIdentifier + let knownBundleID = context._registeredBundles.first(where: { $0.id == referenceID || urlReadablePath($0.displayName) == referenceID.rawValue })?.id, + fallbackResolver.bundleID == knownBundleID else { return nil } @@ -192,7 +192,7 @@ private final class FallbackResolverBasedLinkResolver { allCandidateURLs.append(alreadyResolved.url) // This uses an underscored internal variant of `bundle(identifier:)` to avoid deprecation warnings and remain compatible with legacy data providers. - let currentBundle = context._bundle(identifier: knownBundleIdentifier)! + let currentBundle = context._bundle(identifier: knownBundleID.rawValue)! if !isCurrentlyResolvingSymbolLink { // First look up articles path allCandidateURLs.append(contentsOf: [ diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 085ef6a25..3becc25c6 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -178,11 +178,11 @@ class ExternalReferenceResolverTests: XCTestCase { do { class TestFallbackResolver: ConvertServiceFallbackResolver { - init(bundleIdentifier: String) { - resolver.bundleID = DocumentationBundle.Identifier(rawValue: bundleIdentifier) + init(bundleID: DocumentationBundle.Identifier) { + resolver.bundleID = bundleID } - var bundleIdentifier: String { - resolver.bundleID.rawValue + var bundleID: DocumentationBundle.Identifier { + resolver.bundleID } private var resolver = TestExternalReferenceResolver() func resolve(_ reference: SwiftDocC.TopicReference) -> TopicReferenceResolutionResult { @@ -197,7 +197,7 @@ class ExternalReferenceResolverTests: XCTestCase { } context.configuration.externalDocumentationConfiguration.sources = [:] - context.configuration.convertServiceConfiguration.fallbackResolver = TestFallbackResolver(bundleIdentifier: "org.swift.docc.example") + context.configuration.convertServiceConfiguration.fallbackResolver = TestFallbackResolver(bundleID: "org.swift.docc.example") guard case let .success(resolved) = context.resolve(.unresolved(unresolved), in: parent) else { XCTFail("The reference was unexpectedly unresolved.") From 61cc5e2fd0bc3d0524aa5563f54e6bf21ab94fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:47:02 +0200 Subject: [PATCH 13/17] Use new Identifier type in `SerializableLinkResolutionInformation` --- Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift | 2 +- Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift | 2 +- .../Link Resolution/ExternalPathHierarchyResolver.swift | 2 +- .../Link Resolution/PathHierarchy+Serialization.swift | 4 ++-- .../DocumentationContext/DocumentationContextTests.swift | 2 +- .../Infrastructure/ExternalPathHierarchyResolverTests.swift | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift index 1f21efb3a..726259624 100644 --- a/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift +++ b/Sources/SwiftDocC/Infrastructure/ConvertActionConverter.swift @@ -161,7 +161,7 @@ package enum ConvertActionConverter { if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled { do { - let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) + let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id) try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation) if !emitDigest { diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift b/Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift index 8da62b2ed..63107572e 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift @@ -354,7 +354,7 @@ public struct DocumentationConverter: DocumentationConverterProtocol { if FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled { do { - let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.identifier) + let serializableLinkInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id) try outputConsumer.consume(linkResolutionInformation: serializableLinkInformation) if !emitDigest { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift index dcc16d7e8..2d2325a28 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift @@ -150,7 +150,7 @@ final class ExternalPathHierarchyResolver { continue } let identifier = identifiers[index] - self.resolvedReferences[identifier] = ResolvedTopicReference(id: .init(rawValue: fileRepresentation.bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift) + self.resolvedReferences[identifier] = ResolvedTopicReference(id: fileRepresentation.bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift) } } // Finally, the Identifier -> Symbol mapping can be constructed by iterating over the nodes and looking up the reference for each USR. diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Serialization.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Serialization.swift index 878e31da6..2ca128a33 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Serialization.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+Serialization.swift @@ -148,7 +148,7 @@ public struct SerializableLinkResolutionInformation: Codable { // This type is public so that it can be an argument to a function in `ConvertOutputConsumer` var version: SemanticVersion - var bundleID: String + var bundleID: DocumentationBundle.Identifier var pathHierarchy: PathHierarchy.FileRepresentation // Separate storage of node data because the path hierarchy doesn't know the resolved references for articles. var nonSymbolPaths: [Int: String] @@ -158,7 +158,7 @@ extension PathHierarchyBasedLinkResolver { /// Create a file representation of the link resolver. /// /// The file representation can be decoded in later documentation builds to resolve external links to the content where the link resolver was originally created for. - func prepareForSerialization(bundleID: String) throws -> SerializableLinkResolutionInformation { + func prepareForSerialization(bundleID: DocumentationBundle.Identifier) throws -> SerializableLinkResolutionInformation { var nonSymbolPaths: [Int: String] = [:] let hierarchyFileRepresentation = PathHierarchy.FileRepresentation(pathHierarchy) { identifiers in nonSymbolPaths.reserveCapacity(identifiers.count) diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 811d63ddf..bfbc70939 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -5285,7 +5285,7 @@ let expected = """ return entity.externallyLinkableElementSummaries(context: context, renderNode: renderNode, includeTaskGroups: false) } - let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) + let linkResolutionInformation = try context.linkResolver.localResolver.prepareForSerialization(bundleID: bundle.id) return (linkResolutionInformation, linkSummaries) } diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift index a2d9db632..d711ee693 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift @@ -715,7 +715,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { return entity.externallyLinkableElementSummaries(context: dependencyContext, renderNode: renderNode, includeTaskGroups: false) } - let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.id.rawValue) + let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.id) XCTAssertEqual(linkResolutionInformation.pathHierarchy.nodes.count - linkResolutionInformation.nonSymbolPaths.count, 5 /* 4 symbols & 1 module */) XCTAssertEqual(linkSummaries.count, 5 /* 4 symbols & 1 module */) @@ -995,7 +995,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { let localResolver = try XCTUnwrap(context.linkResolver.localResolver) - let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.id.rawValue) + let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.id) let resolverData = try JSONEncoder().encode(resolverInfo) let roundtripResolverInfo = try JSONDecoder().decode(SerializableLinkResolutionInformation.self, from: resolverData) From 5369b1c59f6283b8f6a9657232d2baa65043cdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:47:36 +0200 Subject: [PATCH 14/17] Use new Identifier type in `ConvertAction/Indexer` --- .../Action/Actions/Convert/ConvertAction.swift | 2 +- .../SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift | 6 +++--- .../SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift index 09946b3d8..8a44fcda0 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift @@ -276,7 +276,7 @@ public struct ConvertAction: AsyncAction { workingDirectory: temporaryFolder, fileManager: fileManager) - let indexer = try Indexer(outputURL: temporaryFolder, bundleIdentifier: bundle.id.rawValue) + let indexer = try Indexer(outputURL: temporaryFolder, bundleID: bundle.id) let context = try DocumentationContext(bundle: bundle, dataProvider: dataProvider, diagnosticEngine: diagnosticEngine, configuration: configuration) diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift index db1f65af2..c8be4857f 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift @@ -32,13 +32,13 @@ extension ConvertAction { /// Creates an indexer that asynchronously indexes nodes and creates the index file on disk. /// - Parameters: /// - outputURL: The target directory to create the index file. - /// - bundleIdentifier: The identifier of the bundle being indexed. - init(outputURL: URL, bundleIdentifier: String) throws { + /// - bundleID: The identifier of the bundle being indexed. + init(outputURL: URL, bundleID: DocumentationBundle.Identifier) throws { let indexURL = outputURL.appendingPathComponent("index", isDirectory: true) indexBuilder = Synchronized( NavigatorIndex.Builder(renderNodeProvider: nil, outputURL: indexURL, - bundleIdentifier: bundleIdentifier, + bundleIdentifier: bundleID.rawValue, sortRootChildrenByName: true, groupByLanguage: true ) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift index 4b8fe0fa2..b839c6012 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift @@ -29,7 +29,7 @@ class ConvertActionIndexerTests: XCTestCase { let renderNode = try converter.convert(context.entity(with: reference)) let tempIndexURL = try createTemporaryDirectory(named: "index") - let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.id.rawValue) + let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleID: bundle.id) indexer.index(renderNode) XCTAssertTrue(indexer.finalize(emitJSON: false, emitLMDB: false).isEmpty) let treeDump = try XCTUnwrap(indexer.dumpTree()) @@ -54,7 +54,7 @@ class ConvertActionIndexerTests: XCTestCase { let renderNode2 = try converter.convert(context.entity(with: reference2)) let tempIndexURL = try createTemporaryDirectory(named: "index") - let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleIdentifier: bundle.id.rawValue) + let indexer = try ConvertAction.Indexer(outputURL: tempIndexURL, bundleID: bundle.id) indexer.index(renderNode1) indexer.index(renderNode2) XCTAssertTrue(indexer.finalize(emitJSON: false, emitLMDB: false).isEmpty) From 4805a05004dc5e51f4c8cc23f9fbbe8d50cf73ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 22 Oct 2024 17:59:49 +0200 Subject: [PATCH 15/17] Prefer `bundleID` over `id` for types that scoped inside bundle --- .../Convert/ConvertService.swift | 2 +- .../Indexing/Navigator/NavigatorIndex.swift | 2 +- .../Infrastructure/DocumentationBundle.swift | 6 +- .../Infrastructure/DocumentationContext.swift | 24 +-- .../Infrastructure/DocumentationCurator.swift | 2 +- .../OutOfProcessReferenceResolver.swift | 26 ++- .../ExternalPathHierarchyResolver.swift | 6 +- .../Link Resolution/LinkResolver.swift | 6 +- .../PathHierarchyBasedLinkResolver.swift | 4 +- .../GeneratedDocumentationTopics.swift | 2 +- .../ResolvedTopicReference+Symbol.swift | 2 +- .../LinkTargets/LinkDestinationSummary.swift | 2 +- Sources/SwiftDocC/Model/Identifier.swift | 58 +++---- .../DocumentationContentRenderer.swift | 6 +- .../RenderHierarchyTranslator.swift | 2 +- .../Rendering/RenderNodeTranslator.swift | 2 +- .../SwiftDocC/DocumentationContextGroup.md | 2 +- .../FilesAndFolders.swift | 2 +- .../Actions/Convert/ConvertAction.swift | 2 +- .../Action/Actions/Merge/MergeAction.swift | 2 +- .../Benchmark/ExternalTopicsHashTests.swift | 2 +- .../Benchmark/TopicAnchorHashTests.swift | 2 +- .../Benchmark/TopicGraphHashTests.swift | 6 +- .../Converter/RenderNodeCodableTests.swift | 4 +- ...nderNodeVariantOverridesApplierTests.swift | 4 +- .../TopicRenderReferenceEncoderTests.swift | 6 +- .../Diagnostics/DiagnosticTests.swift | 2 +- .../Indexing/IndexingTests.swift | 10 +- .../Indexing/NavigatorIndexTests.swift | 6 +- .../Infrastructure/AnchorSectionTests.swift | 18 +- .../AutoCapitalizationTests.swift | 6 +- .../AutomaticCurationTests.swift | 40 ++--- ...ext+MixedLanguageLinkResolutionTests.swift | 2 +- .../DocumentationContext+RootPageTests.swift | 2 +- .../DocumentationContextTests.swift | 164 +++++++++--------- .../DocumentationCuratorTests.swift | 34 ++-- .../ExternalPathHierarchyResolverTests.swift | 4 +- .../ExternalReferenceResolverTests.swift | 52 +++--- .../Infrastructure/NodeTagsTests.swift | 4 +- .../NodeURLGeneratorTests.swift | 8 +- .../Infrastructure/PathHierarchyTests.swift | 2 +- .../PresentationURLGeneratorTests.swift | 8 +- .../ReferenceResolverTests.swift | 40 ++--- .../ResolvedTopicReferenceTests.swift | 10 +- ...SymbolGraphRelationshipsBuilderTests.swift | 10 +- .../TestExternalReferenceResolvers.swift | 4 +- .../Infrastructure/TopicGraphTests.swift | 2 +- .../LinkDestinationSummaryTests.swift | 20 +-- .../Model/DocumentationNodeTests.swift | 2 +- .../Model/IdentifierTests.swift | 32 ++-- .../Model/LineHighlighterTests.swift | 2 +- .../ParametersAndReturnValidatorTests.swift | 14 +- ...opertyListPossibleValuesSectionTests.swift | 8 +- .../Model/RenderContentMetadataTests.swift | 14 +- .../RenderHierarchyTranslatorTests.swift | 4 +- .../Model/RenderNodeDiffingBundleTests.swift | 4 +- .../Model/RenderNodeSerializationTests.swift | 10 +- .../Model/ResourceReferenceTests.swift | 2 +- .../SemaToRenderNodeMultiLanguageTests.swift | 2 +- .../Model/SemaToRenderNodeTests.swift | 134 +++++++------- .../SwiftDocCTests/Model/TaskGroupTests.swift | 2 +- .../Rendering/AutomaticSeeAlsoTests.swift | 18 +- .../AvailabilityRenderOrderTests.swift | 2 +- .../ConstraintsRenderSectionTests.swift | 16 +- .../DeclarationsRenderSectionTests.swift | 10 +- .../Rendering/DefaultAvailabilityTests.swift | 16 +- .../DefaultCodeListingSyntaxTests.swift | 2 +- .../Rendering/DeprecationSummaryTests.swift | 14 +- .../DocumentationContentRendererTests.swift | 4 +- .../Rendering/ExternalLinkTitleTests.swift | 2 +- .../MentionsRenderSectionTests.swift | 6 +- .../Rendering/PageKindTests.swift | 2 +- .../Rendering/PlatformAvailabilityTests.swift | 16 +- .../Rendering/RESTSymbolsTests.swift | 2 +- ...enderBlockContent_ThematicBreakTests.swift | 6 +- .../RenderContentCompilerTests.swift | 6 +- .../Rendering/RenderMetadataTests.swift | 6 +- ...derNodeTranslatorSymbolVariantsTests.swift | 28 +-- .../Rendering/RenderNodeTranslatorTests.swift | 66 +++---- .../SwiftDocCTests/Rendering/RoleTests.swift | 6 +- .../Rendering/SampleDownloadTests.swift | 2 +- .../Rendering/TermListTests.swift | 6 +- .../ArticleSymbolMentionsTests.swift | 10 +- .../Semantics/DoxygenTests.swift | 2 +- .../Semantics/TutorialArticleTests.swift | 8 +- .../Semantics/TutorialTests.swift | 8 +- .../Semantics/VideoMediaTests.swift | 2 +- .../Semantics/VolumeTests.swift | 2 +- .../XCTestCase+LoadingTestData.swift | 4 +- .../ConvertActionIndexerTests.swift | 6 +- .../ConvertActionTests.swift | 2 +- .../JSONEncodingRenderNodeWriterTests.swift | 2 +- .../OutOfProcessReferenceResolverTests.swift | 14 +- .../SemanticAnalyzerTests.swift | 2 +- 94 files changed, 578 insertions(+), 582 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift index 7951f9b74..0ca8a3cc3 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift @@ -267,7 +267,7 @@ public struct ConvertService: DocumentationService { .compactMap { (value, isDocumentationExtensionContent) -> (ResolvedTopicReference, RenderReferenceStore.TopicContent)? in let (topicReference, article) = value - guard let bundle = context.bundle, bundle.id == topicReference.id else { return nil } + guard let bundle = context.bundle, bundle.id == topicReference.bundleID else { return nil } let renderer = DocumentationContentRenderer(documentationContext: context, bundle: bundle) let documentationNodeKind: DocumentationNode.Kind = isDocumentationExtensionContent ? .unknownSymbol : .article diff --git a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift index d03a99f1d..2121cb94f 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift @@ -438,7 +438,7 @@ extension ResolvedTopicReference { let normalizedPath = NodeURLGenerator.fileSafeReferencePath(self, lowercased: true) return NavigatorIndex.Identifier( - bundleIdentifier: id.rawValue.lowercased(), + bundleIdentifier: bundleID.rawValue.lowercased(), path: "/" + normalizedPath, fragment: fragment, languageIdentifier: languageIdentifier diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift index 794f81eef..d0742f212 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift @@ -127,9 +127,9 @@ public struct DocumentationBundle { self.customHeader = customHeader self.customFooter = customFooter self.themeSettings = themeSettings - self.rootReference = ResolvedTopicReference(id: info.id, path: "/", sourceLanguage: .swift) - self.documentationRootReference = ResolvedTopicReference(id: info.id, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) - self.tutorialTableOfContentsContainer = ResolvedTopicReference(id: info.id, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) + self.rootReference = ResolvedTopicReference(bundleID: info.id, path: "/", sourceLanguage: .swift) + self.documentationRootReference = ResolvedTopicReference(bundleID: info.id, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift) + self.tutorialTableOfContentsContainer = ResolvedTopicReference(bundleID: info.id, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift) self.tutorialsContainerReference = tutorialTableOfContentsContainer.appendingPath(urlReadablePath(info.displayName)) self.articlesDocumentationRootReference = documentationRootReference.appendingPath(urlReadablePath(info.displayName)) } diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index a164fa452..76c06e3f4 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -915,7 +915,7 @@ public class DocumentationContext { let (url, analyzed) = analyzedDocument let path = NodeURLGenerator.pathForSemantic(analyzed, source: url, bundle: bundle) - let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift) // Since documentation extensions' filenames have no impact on the URL of pages, there is no need to enforce unique filenames for them. // At this point we consider all articles with an H1 containing link a "documentation extension." @@ -1336,7 +1336,7 @@ public class DocumentationContext { let symbolPath = NodeURLGenerator.Path.documentation(path: url.components.path).stringValue let symbolReference = ResolvedTopicReference( - id: reference.id, + bundleID: reference.bundleID, path: symbolPath, fragment: nil, sourceLanguages: reference.sourceLanguages @@ -1948,7 +1948,7 @@ public class DocumentationContext { let title = articleResult.source.deletingPathExtension().lastPathComponent // Create a new root-looking reference let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: NodeURLGenerator.Path.documentation(path: title).stringValue, sourceLanguages: [DocumentationContext.defaultLanguage(in: nil /* article-only content has no source language information */)] ) @@ -1987,7 +1987,7 @@ public class DocumentationContext { let path = NodeURLGenerator.Path.documentation(path: title).stringValue let sourceLanguage = DocumentationContext.defaultLanguage(in: []) - let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguages: [sourceLanguage]) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguages: [sourceLanguage]) let graphNode = TopicGraph.Node(reference: reference, kind: .module, source: .external, title: title) topicGraph.addNode(graphNode) @@ -2052,7 +2052,7 @@ public class DocumentationContext { let defaultSourceLanguage = defaultLanguage(in: availableSourceLanguages) let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: path, sourceLanguages: availableSourceLanguages // FIXME: Pages in article-only catalogs should not be inferred as "Swift" as a fallback @@ -2687,12 +2687,12 @@ public class DocumentationContext { */ private func unregister(_ bundle: DocumentationBundle) { let referencesToRemove = topicGraph.nodes.keys.filter { - $0.id == bundle.id + $0.bundleID == bundle.id } for reference in referencesToRemove { - topicGraph.edges[reference]?.removeAll(where: { $0.id == bundle.id }) - topicGraph.reverseEdges[reference]?.removeAll(where: { $0.id == bundle.id }) + topicGraph.edges[reference]?.removeAll(where: { $0.bundleID == bundle.id }) + topicGraph.reverseEdges[reference]?.removeAll(where: { $0.bundleID == bundle.id }) topicGraph.nodes[reference] = nil } } @@ -2738,7 +2738,7 @@ public class DocumentationContext { } private func externalEntity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity? { - return configuration.externalDocumentationConfiguration.sources[reference.id].map({ $0.entity(with: reference) }) + return configuration.externalDocumentationConfiguration.sources[reference.bundleID].map({ $0.entity(with: reference) }) ?? configuration.convertServiceConfiguration.fallbackResolver?.entityIfPreviouslyResolved(with: reference) } @@ -2904,7 +2904,7 @@ public class DocumentationContext { /// - asset: The new asset for this name. /// - parent: The topic where the asset is referenced. public func updateAsset(named name: String, asset: DataAsset, in parent: ResolvedTopicReference) { - assetManagers[parent.id]?.update(name: name, asset: asset) + assetManagers[parent.bundleID]?.update(name: name, asset: asset) } /// Attempt to resolve an asset given its name and the topic it's referenced in. @@ -2915,7 +2915,7 @@ public class DocumentationContext { /// - type: A restriction for what type of asset to resolve. /// - Returns: The data that's associated with an image asset if it was found, otherwise `nil`. public func resolveAsset(named name: String, in parent: ResolvedTopicReference, withType type: AssetType? = nil) -> DataAsset? { - resolveAsset(named: name, bundleID: parent.id, withType: type) + resolveAsset(named: name, bundleID: parent.bundleID, withType: type) } func resolveAsset(named name: String, bundleID: DocumentationBundle.Identifier, withType expectedType: AssetType?) -> DataAsset? { @@ -2959,7 +2959,7 @@ public class DocumentationContext { /// /// - Returns: The best matching storage key if it was found, otherwise `nil`. public func identifier(forAssetName name: String, in parent: ResolvedTopicReference) -> String? { - if let assetManager = assetManagers[parent.id] { + if let assetManager = assetManagers[parent.bundleID] { if let localName = assetManager.bestKey(forAssetName: name) { return localName } else if let fallbackAssetManager = configuration.convertServiceConfiguration.fallbackResolver { diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift index 80057ce23..b310940a5 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift @@ -94,7 +94,7 @@ struct DocumentationCurator { let sourceArticlePath = NodeURLGenerator.Path.article(bundleName: bundle.displayName, articleName: articleFilename).stringValue let reference = ResolvedTopicReference( - id: resolved.id, + bundleID: resolved.bundleID, path: sourceArticlePath, sourceLanguages: resolved.sourceLanguages) diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index d57970308..b21acc1f7 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -53,11 +53,11 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") public var bundleIdentifier: String { - id.rawValue + bundleID.rawValue } /// The bundle identifier for the reference resolver in the other process. - public let id: DocumentationBundle.Identifier + public let bundleID: DocumentationBundle.Identifier /// Creates a new reference resolver that interacts with another executable. /// @@ -82,13 +82,13 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE throw Error.invalidBundleIdentifierOutputFromExecutable(processLocation) } - self.id = .init(rawValue: decodedBundleIdentifier) + self.bundleID = .init(rawValue: decodedBundleIdentifier) self.externalLinkResolvingClient = longRunningProcess } - @available(*, deprecated, renamed: "init(id:server:convertRequestIdentifier:)", message: "Use 'init(id:server:convertRequestIdentifier:)' instead. This deprecated API will be removed after 6.2 is released") + @available(*, deprecated, renamed: "init(bundleID:server:convertRequestIdentifier:)", message: "Use 'init(bundleID:server:convertRequestIdentifier:)' instead. This deprecated API will be removed after 6.2 is released") public init(bundleIdentifier: String, server: DocumentationServer, convertRequestIdentifier: String?) throws { - self.id = .init(rawValue: bundleIdentifier) + self.bundleID = .init(rawValue: bundleIdentifier) self.externalLinkResolvingClient = LongRunningService( server: server, convertRequestIdentifier: convertRequestIdentifier) } @@ -102,7 +102,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE /// - server: The server to send link resolution requests to. /// - convertRequestIdentifier: The identifier that the resolver will use for convert requests that it sends to the server. public init(id: DocumentationBundle.Identifier, server: DocumentationServer, convertRequestIdentifier: String?) throws { - self.id = id + self.bundleID = id self.externalLinkResolvingClient = LongRunningService( server: server, convertRequestIdentifier: convertRequestIdentifier) } @@ -115,7 +115,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE return resolved case let .unresolved(unresolvedReference): - guard unresolvedReference.id == id else { + guard unresolvedReference.bundleID == bundleID else { fatalError(""" Attempted to resolve a local reference externally: \(unresolvedReference.description.singleQuoted). DocC should never pass a reference to an external resolver unless it matches that resolver's bundle identifier. @@ -147,7 +147,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE guard let resolvedInformation = try? resolveInformationForSymbolIdentifier(preciseIdentifier) else { return nil } let reference = ResolvedTopicReference( - id: "com.externally.resolved.symbol", + bundleID: "com.externally.resolved.symbol", path: "/\(preciseIdentifier)", sourceLanguages: sourceLanguages(for: resolvedInformation) ) @@ -255,7 +255,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE private func resolvedReference(for resolvedInformation: ResolvedInformation) -> ResolvedTopicReference { return ResolvedTopicReference( - id: id, + bundleID: bundleID, path: resolvedInformation.url.path, fragment: resolvedInformation.url.fragment, sourceLanguages: sourceLanguages(for: resolvedInformation) @@ -779,13 +779,13 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { } func resolveInformationForAsset(named assetName: String) throws -> DataAsset { - let assetReference = AssetReference(assetName: assetName, bundleID: id) + let assetReference = AssetReference(assetName: assetName, bundleID: bundleID) if let asset = assetCache[assetReference] { return asset } let response = try externalLinkResolvingClient.sendAndWait( - request: Request.asset(AssetReference(assetName: assetName, bundleID: id)) + request: Request.asset(AssetReference(assetName: assetName, bundleID: bundleID)) ) as Response switch response { @@ -798,8 +798,4 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { throw Error.unexpectedResponse(response: response, requestDescription: "asset") } } - - var bundleID: DocumentationBundle.Identifier { - id - } } diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift index 2d2325a28..3a08edb0f 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift @@ -98,7 +98,7 @@ final class ExternalPathHierarchyResolver { else { return nil } - return ResolvedTopicReference(id: .init(rawValue: bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift) + return ResolvedTopicReference(bundleID: .init(rawValue: bundleID), path: url.path, fragment: url.fragment, sourceLanguage: .swift) } let dependencies = RenderReferenceDependencies( topicReferences: topicReferences, @@ -126,7 +126,7 @@ final class ExternalPathHierarchyResolver { symbols.reserveCapacity(linkDestinationSummaries.count) for entity in linkDestinationSummaries { let reference = ResolvedTopicReference( - id: .init(rawValue: entity.referenceURL.host!), + bundleID: .init(rawValue: entity.referenceURL.host!), path: entity.referenceURL.path, fragment: entity.referenceURL.fragment, sourceLanguage: entity.language @@ -150,7 +150,7 @@ final class ExternalPathHierarchyResolver { continue } let identifier = identifiers[index] - self.resolvedReferences[identifier] = ResolvedTopicReference(id: fileRepresentation.bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift) + self.resolvedReferences[identifier] = ResolvedTopicReference(bundleID: fileRepresentation.bundleID, path: url.path, fragment: url.fragment, sourceLanguage: .swift) } } // Finally, the Identifier -> Symbol mapping can be constructed by iterating over the nodes and looking up the reference for each USR. diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index 204544ef9..6896f23d4 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -92,7 +92,7 @@ public class LinkResolver { } // Check if this is a link to an external documentation source that should have previously been resolved in `DocumentationContext.preResolveExternalLinks(...)` - if let bundleID = unresolvedReference.id, + if let bundleID = unresolvedReference.bundleID, !context._registeredBundles.contains(where: { $0.id == bundleID || urlReadablePath($0.displayName) == bundleID.rawValue }) { return .failure(unresolvedReference, TopicReferenceResolutionErrorInfo("No external resolver registered for '\(bundleID)'.")) @@ -169,7 +169,7 @@ private final class FallbackResolverBasedLinkResolver { private func resolve(_ unresolvedReference: UnresolvedTopicReference, in parent: ResolvedTopicReference, fromSymbolLink isCurrentlyResolvingSymbolLink: Bool, context: DocumentationContext) -> TopicReferenceResolutionResult? { // Check if a fallback reference resolver should resolve this - let referenceID = unresolvedReference.id ?? parent.id + let referenceID = unresolvedReference.bundleID ?? parent.bundleID guard let fallbackResolver = context.configuration.convertServiceConfiguration.fallbackResolver, // This uses an underscored internal variant of `registeredBundles` to avoid deprecation warnings and remain compatible with legacy data providers. let knownBundleID = context._registeredBundles.first(where: { $0.id == referenceID || urlReadablePath($0.displayName) == referenceID.rawValue })?.id, @@ -184,7 +184,7 @@ private final class FallbackResolverBasedLinkResolver { var allCandidateURLs = [URL]() let alreadyResolved = ResolvedTopicReference( - id: referenceID, + bundleID: referenceID, path: unresolvedReference.path.prependingLeadingSlash, fragment: unresolvedReference.topicURL.components.fragment, sourceLanguages: parent.sourceLanguages diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift index ea5e28b83..6a7528c84 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift @@ -28,7 +28,7 @@ final class PathHierarchyBasedLinkResolver { func unregisterBundle(identifier: DocumentationBundle.Identifier) { var newMap = BidirectionalMap() for (id, reference) in resolvedReferenceMap { - if reference.id == identifier { + if reference.bundleID == identifier { pathHierarchy.removeNodeWithID(id) } else { newMap[id] = reference @@ -301,7 +301,7 @@ final class PathHierarchyBasedLinkResolver { } return ResolvedTopicReference( - id: bundle.documentationRootReference.id, + bundleID: bundle.documentationRootReference.bundleID, path: NodeURLGenerator.Path.documentationFolder + path, sourceLanguages: symbol.sourceLanguages ) diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift index d1cd65535..003f6b64a 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift @@ -107,7 +107,7 @@ enum GeneratedDocumentationTopics { // Create the collection topic reference let collectionReference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: NodeURLGenerator.Path.documentationCuration( parentPath: parent.path, articleName: title diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift index 4f121df98..c03c5d306 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/ResolvedTopicReference+Symbol.swift @@ -20,7 +20,7 @@ extension ResolvedTopicReference { let path = symbolReference.path.isEmpty ? "" : "/" + symbolReference.path self.init( - id: bundle.documentationRootReference.id, + bundleID: bundle.documentationRootReference.bundleID, path: bundle.documentationRootReference.appendingPath(moduleName + path).path, fragment: nil, sourceLanguages: symbolReference.interfaceLanguages diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index fc06ae820..5b055d4ed 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -311,7 +311,7 @@ public extension DocumentationNode { renderNode: RenderNode, includeTaskGroups: Bool = true ) -> [LinkDestinationSummary] { - guard let bundle = context.bundle, bundle.id == reference.id else { + guard let bundle = context.bundle, bundle.id == reference.bundleID else { // Don't return anything for external references that don't have a bundle in the context. return [] } diff --git a/Sources/SwiftDocC/Model/Identifier.swift b/Sources/SwiftDocC/Model/Identifier.swift index 9b093e0fa..4a0815f55 100644 --- a/Sources/SwiftDocC/Model/Identifier.swift +++ b/Sources/SwiftDocC/Model/Identifier.swift @@ -164,7 +164,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } } } - + /// The URL scheme for `doc://` links. public static let urlScheme = "doc" @@ -176,14 +176,14 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// The storage for the resolved topic reference's state. let _storage: Storage - @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") + @available(*, deprecated, renamed: "bundleID", message: "Use 'bundleID' instead. This deprecated API will be removed after 6.2 is released") public var bundleIdentifier: String { - id.rawValue + bundleID.rawValue } /// The identifier of the bundle that owns this documentation topic. - public var id: DocumentationBundle.Identifier { - _storage.id + public var bundleID: DocumentationBundle.Identifier { + _storage.bundleID } /// The absolute path from the bundle to this topic, delimited by `/`. @@ -212,13 +212,13 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } /// - Note: The `path` parameter is escaped to a path readable string. - public init(id: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguage: SourceLanguage) { - self.init(id: id, path: path, fragment: fragment, sourceLanguages: [sourceLanguage]) + public init(bundleID: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguage: SourceLanguage) { + self.init(bundleID: bundleID, path: path, fragment: fragment, sourceLanguages: [sourceLanguage]) } - public init(id: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguages: Set) { + public init(bundleID: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguages: Set) { self.init( - id: id, + bundleID: bundleID, urlReadablePath: urlReadablePath(path), urlReadableFragment: fragment.map(urlReadableFragment(_:)), sourceLanguages: sourceLanguages @@ -230,21 +230,21 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } @available(*, deprecated, renamed: "init(id:path:fragment:sourceLanguages:)", message: "Use 'init(id:path:fragment:sourceLanguages:)' instead. This deprecated API will be removed after 6.2 is released") public init(bundleIdentifier: String, path: String, fragment: String? = nil, sourceLanguages: Set) { - self.init(id: .init(rawValue: bundleIdentifier), path: path, fragment: fragment, sourceLanguages: sourceLanguages) + self.init(bundleID: .init(rawValue: bundleIdentifier), path: path, fragment: fragment, sourceLanguages: sourceLanguages) } - private init(id: DocumentationBundle.Identifier, urlReadablePath: String, urlReadableFragment: String? = nil, sourceLanguages: Set) { + private init(bundleID: DocumentationBundle.Identifier, urlReadablePath: String, urlReadableFragment: String? = nil, sourceLanguages: Set) { precondition(!sourceLanguages.isEmpty, "ResolvedTopicReference.sourceLanguages cannot be empty") // Check for a cached instance of the reference let key = ReferenceKey(path: urlReadablePath, fragment: urlReadableFragment, sourceLanguages: sourceLanguages) - let cached = Self.sharedPool.sync { $0[id]?[key] } + let cached = Self.sharedPool.sync { $0[bundleID]?[key] } if let resolved = cached { self = resolved return } _storage = Storage( - id: id, + bundleID: bundleID, path: urlReadablePath, fragment: urlReadableFragment, sourceLanguages: sourceLanguages @@ -253,7 +253,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString // Cache the reference Self.sharedPool.sync { sharedPool in // If we have a shared pool for this bundle identifier, cache the reference - sharedPool[id]?[key] = self + sharedPool[bundleID]?[key] = self } } @@ -298,7 +298,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString decoder.registerReferences([url.absoluteString]) - self.init(id: .init(rawValue: bundleIdentifier), path: url.path, fragment: url.fragment, sourceLanguage: interfaceLanguage) + self.init(bundleID: .init(rawValue: bundleIdentifier), path: url.path, fragment: url.fragment, sourceLanguage: interfaceLanguage) } /// Creates a new topic reference with the given fragment. @@ -317,7 +317,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// - Returns: The resulting topic reference. public func withFragment(_ fragment: String?) -> ResolvedTopicReference { let newReference = ResolvedTopicReference( - id: id, + bundleID: bundleID, path: path, fragment: fragment.map(urlReadableFragment), sourceLanguages: sourceLanguages @@ -334,7 +334,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// - Returns: The resulting topic reference. public func appendingPath(_ path: String) -> ResolvedTopicReference { let newReference = ResolvedTopicReference( - id: id, + bundleID: bundleID, urlReadablePath: url.appendingPathComponent(urlReadablePath(path), isDirectory: false).path, sourceLanguages: sourceLanguages ) @@ -355,7 +355,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } let newPath = url.appendingPathComponent(referencePath, isDirectory: false).path let newReference = ResolvedTopicReference( - id: id, + bundleID: bundleID, urlReadablePath: newPath, urlReadableFragment: reference.fragment.map(urlReadableFragment), sourceLanguages: sourceLanguages @@ -367,7 +367,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString public func removingLastPathComponent() -> ResolvedTopicReference { let newPath = String(pathComponents.dropLast().joined(separator: "/").dropFirst()) let newReference = ResolvedTopicReference( - id: id, + bundleID: bundleID, urlReadablePath: newPath, urlReadableFragment: fragment, sourceLanguages: sourceLanguages @@ -387,7 +387,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } return ResolvedTopicReference( - id: id, + bundleID: bundleID, urlReadablePath: path, urlReadableFragment: fragment, sourceLanguages: combinedSourceLanguages @@ -404,7 +404,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString } return ResolvedTopicReference( - id: id, + bundleID: bundleID, urlReadablePath: path, urlReadableFragment: fragment, sourceLanguages: sourceLanguages @@ -460,7 +460,7 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString /// /// This is a reference type which allows ``ResolvedTopicReference`` to have copy-on-write behavior. class Storage { - let id: DocumentationBundle.Identifier + let bundleID: DocumentationBundle.Identifier let path: String let fragment: String? let sourceLanguages: Set @@ -473,20 +473,20 @@ public struct ResolvedTopicReference: Hashable, Codable, Equatable, CustomString let absoluteString: String init( - id: DocumentationBundle.Identifier, + bundleID: DocumentationBundle.Identifier, path: String, fragment: String? = nil, sourceLanguages: Set ) { - self.id = id + self.bundleID = bundleID self.path = path self.fragment = fragment self.sourceLanguages = sourceLanguages - self.identifierPathAndFragment = "\(id)\(path)\(fragment ?? "")" + self.identifierPathAndFragment = "\(bundleID)\(path)\(fragment ?? "")" var components = URLComponents() components.scheme = ResolvedTopicReference.urlScheme - components.host = id.rawValue + components.host = bundleID.rawValue components.path = path components.fragment = fragment self.url = components.url! @@ -528,13 +528,13 @@ public struct UnresolvedTopicReference: Hashable, CustomStringConvertible { /// The URL as originally spelled. public let topicURL: ValidatedURL - @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") + @available(*, deprecated, renamed: "bundleID", message: "Use 'bundleID' instead. This deprecated API will be removed after 6.2 is released") public var bundleIdentifier: String? { - id?.rawValue + bundleID?.rawValue } /// The bundle identifier, if one was provided in the host name component of the original URL. - public var id: DocumentationBundle.Identifier? { + public var bundleID: DocumentationBundle.Identifier? { topicURL.components.host.map { .init(rawValue: $0) } } diff --git a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift index 3c8e02f88..2647f1c4b 100644 --- a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift +++ b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift @@ -329,7 +329,7 @@ public class DocumentationContentRenderer { if kind == .section { // Sections don't have their own abstract so take the one of the container symbol. let containerReference = ResolvedTopicReference( - id: reference.id, + bundleID: reference.bundleID, path: reference.path, sourceLanguages: reference.sourceLanguages ) @@ -502,14 +502,14 @@ public class DocumentationContentRenderer { } // For external links, verify they've resolved successfully and return `nil` otherwise. - if linkHost != reference.id.rawValue { + if linkHost != reference.bundleID.rawValue { if let url = ValidatedURL(destination), case .success(let externalReference) = documentationContext.externallyResolvedLinks[url] { return externalReference } return nil } return ResolvedTopicReference( - id: reference.id, + bundleID: reference.bundleID, path: destination.path, sourceLanguages: node.availableSourceLanguages ) diff --git a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift index daceacfa8..adeed34c4 100644 --- a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift @@ -161,7 +161,7 @@ struct RenderHierarchyTranslator { if let tutorial = (try? context.entity(with: tutorialReference).semantic) as? Tutorial, let assessments = tutorial.assessments, !assessments.questions.isEmpty { // Add hardcoded assessment section. - let assessmentReference = ResolvedTopicReference(id: tutorialReference.id, path: tutorialReference.path, fragment: RenderHierarchyTranslator.assessmentsAnchor, sourceLanguage: .swift) + let assessmentReference = ResolvedTopicReference(bundleID: tutorialReference.bundleID, path: tutorialReference.path, fragment: RenderHierarchyTranslator.assessmentsAnchor, sourceLanguage: .swift) renderHierarchyTutorial.landmarks.append(RenderHierarchyLandmark(reference: RenderReferenceIdentifier(assessmentReference.absoluteString), kind: .assessment)) let urlGenerator = PresentationURLGenerator(context: context, baseURL: bundle.baseURL) diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index de3a4492f..8341f9943 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -1717,7 +1717,7 @@ public struct RenderNodeTranslator: SemanticVisitor { } let media = ResourceReference(bundleID: oldMedia.bundleID, path: mediaIdentifier) - guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleID: identifier.id) + guard let resolvedAssets = renderContext?.store.content(forAssetNamed: media.path, bundleID: identifier.bundleID) ?? context.resolveAsset(named: media.path, in: identifier) else { return nil diff --git a/Sources/SwiftDocC/SwiftDocC.docc/SwiftDocC/DocumentationContextGroup.md b/Sources/SwiftDocC/SwiftDocC.docc/SwiftDocC/DocumentationContextGroup.md index da4e63231..009f54dc4 100644 --- a/Sources/SwiftDocC/SwiftDocC.docc/SwiftDocC/DocumentationContextGroup.md +++ b/Sources/SwiftDocC/SwiftDocC.docc/SwiftDocC/DocumentationContextGroup.md @@ -27,7 +27,7 @@ Use ``DocumentationContext/entity(with:)`` to access a documentation node by its ```swift let reference = ResolvedTopicReference( - bundleIdentifier: "com.mybundle", + bundleID: "com.mybundle", path: "/documentation/ValidationKit/EmailValidator", fragment: nil, sourceLanguage: .swift) diff --git a/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift b/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift index 5fccd4bf3..856d22fea 100644 --- a/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift +++ b/Sources/SwiftDocCTestUtilities/FilesAndFolders.swift @@ -300,7 +300,7 @@ extension Folder { } private func makeMinimalTestRenderNode(path: String) -> RenderNode { - let reference = ResolvedTopicReference(id: "org.swift.test", path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.test", path: path, sourceLanguage: .swift) let rawReference = reference.url.absoluteString let title = path.components(separatedBy: "/").last ?? path diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift index 8a44fcda0..5df21928f 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/ConvertAction.swift @@ -160,7 +160,7 @@ public struct ConvertAction: AsyncAction { } if let outOfProcessResolver { - configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.id] = outOfProcessResolver + configuration.externalDocumentationConfiguration.sources[outOfProcessResolver.bundleID] = outOfProcessResolver configuration.externalDocumentationConfiguration.globalSymbolResolver = outOfProcessResolver } configuration.externalDocumentationConfiguration.dependencyArchives = dependencies diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift index c0790ff0e..4f41ce931 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift @@ -103,7 +103,7 @@ struct MergeAction: AsyncAction { let languages = combinedIndex.interfaceLanguages.keys.map { SourceLanguage(id: $0) } let language = languages.sorted().first ?? .swift - let reference = ResolvedTopicReference(id: .init(rawValue: landingPageName), path: "/documentation", sourceLanguage: language) + let reference = ResolvedTopicReference(bundleID: .init(rawValue: landingPageName), path: "/documentation", sourceLanguage: language) let rootRenderReferences = try readRootNodeRenderReferencesIn(dataDirectory: targetURL.appendingPathComponent("data", isDirectory: true)) diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index 2bcd77861..baf4a1aac 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -20,7 +20,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { /// A resolver returning mock symbols. class TestSymbolResolver: GlobalExternalSymbolResolver { func symbolReferenceAndEntity(withPreciseIdentifier preciseIdentifier: String) -> (ResolvedTopicReference, LinkResolver.ExternalEntity)? { - let reference = ResolvedTopicReference(id: "com.test.symbols", path: "/\(preciseIdentifier)", sourceLanguage: SourceLanguage.swift) + let reference = ResolvedTopicReference(bundleID: "com.test.symbols", path: "/\(preciseIdentifier)", sourceLanguage: SourceLanguage.swift) let entity = LinkResolver.ExternalEntity( topicRenderReference: TopicRenderReference( identifier: .init(preciseIdentifier), diff --git a/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift index 453e97849..682dd1429 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicAnchorHashTests.swift @@ -50,7 +50,7 @@ class TopicAnchorHashTests: XCTestCase { } // Add a new section to verify that the hash will change - let newReference = ResolvedTopicReference(id: "com.bundle.id", path: "/documentation/new#section", sourceLanguage: .swift) + let newReference = ResolvedTopicReference(bundleID: "com.bundle.id", path: "/documentation/new#section", sourceLanguage: .swift) context.nodeAnchorSections[newReference] = AnchorSection(reference: newReference, title: "New Sub-section") // Now verify that the topic anchor hash changed after the change diff --git a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift index 878bcc512..52fc62ee3 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift @@ -51,7 +51,7 @@ class TopicGraphHashTests: XCTestCase { } // Here we'll add a completely new node and curated it in the topic graph - let newNode = TopicGraph.Node(reference: .init(id: #function, path: "/newSymbol", sourceLanguage: .swift), kind: .article, source: .external, title: "External Article") + let newNode = TopicGraph.Node(reference: .init(bundleID: #function, path: "/newSymbol", sourceLanguage: .swift), kind: .article, source: .external, title: "External Article") context.topicGraph.addNode(newNode) // We can force unwrap below because we're guaranteed to find at least one node which is not `newNode` context.topicGraph.addEdge(from: context.topicGraph.nodes.values.first(where: { existingNode -> Bool in @@ -105,7 +105,7 @@ class TopicGraphHashTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -117,7 +117,7 @@ class TopicGraphHashTests: XCTestCase { ]) // Verify correct hierarchy under `MyKit` in the topic graph dump including external symbols. - let myKitRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let myKitRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let myKitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(myKitRef)) let expectedHierarchyWithExternalSymbols = """ diff --git a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift index d6e423ba5..5dd3a17c7 100644 --- a/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift +++ b/Tests/SwiftDocCTests/Converter/RenderNodeCodableTests.swift @@ -15,7 +15,7 @@ import Markdown class RenderNodeCodableTests: XCTestCase { var bareRenderNode = RenderNode( - identifier: .init(id: "com.bundle", path: "/", sourceLanguage: .swift), + identifier: .init(bundleID: "com.bundle", path: "/", sourceLanguage: .swift), kind: .article ) @@ -189,7 +189,7 @@ class RenderNodeCodableTests: XCTestCase { ) let reference = ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/documentation/test/customTopicSectionStyle", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift b/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift index 2b4154b82..52679fd2b 100644 --- a/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift +++ b/Tests/SwiftDocCTests/Converter/Rewriter/RenderNodeVariantOverridesApplierTests.swift @@ -77,7 +77,7 @@ class RenderNodeVariantOverridesApplierTests: XCTestCase { renderNode.addVariantOverride( pointerComponents: ["identifier"], value: ResolvedTopicReference( - id: "new-bundle-identifier", + bundleID: "new-bundle-identifier", path: "/path", fragment: nil, sourceLanguage: .objectiveC @@ -193,7 +193,7 @@ class RenderNodeVariantOverridesApplierTests: XCTestCase { ) throws { var renderNode = RenderNode( identifier: ResolvedTopicReference( - id: "bundle-identifier", + bundleID: "bundle-identifier", path: "", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift index fea4c4efc..4b18833e4 100644 --- a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift +++ b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift @@ -14,7 +14,7 @@ import XCTest class TopicRenderReferenceEncoderTests: XCTestCase { func testRenderNodeSkipsReferences() throws { - var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(bundleID: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) node.references = [ "reference1": TopicRenderReference(identifier: .init("reference1"), title: "myFunction", abstract: [], url: "/documentation/MyClass/myFunction", kind: .symbol, estimatedTime: nil), ] @@ -51,7 +51,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { func testTopicReferenceEncoder() throws { // Create a render node - var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(bundleID: "bundle", path: "/documentation/MyClass", sourceLanguage: .swift), kind: .article) node.references = [ "reference1": TopicRenderReference(identifier: .init("reference1"), title: "myFunction", abstract: [], url: "/documentation/MyClass/myFunction", kind: .symbol, estimatedTime: nil), ] @@ -124,7 +124,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { // Create many render nodes. let nodes = (0..<1000) .map({ i -> RenderNode in - var node = RenderNode(identifier: .init(id: "bundle", path: "/documentation/MyClass\(i)", sourceLanguage: .swift), kind: .article) + var node = RenderNode(identifier: .init(bundleID: "bundle", path: "/documentation/MyClass\(i)", sourceLanguage: .swift), kind: .article) node.references = references return node }) diff --git a/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift b/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift index 9201ca947..7a079febb 100644 --- a/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift +++ b/Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift @@ -84,7 +84,7 @@ class DiagnosticTests: XCTestCase { let content = "Test a ``Reference`` in a sentence." let markup = Document(parsing: content, source: URL(string: "/tmp/foo.symbols.json"), options: .parseSymbolLinks) - var resolver = ReferenceResolver(context: context, bundle: bundle, rootReference: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + var resolver = ReferenceResolver(context: context, bundle: bundle, rootReference: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) // Resolve references _ = resolver.visitMarkup(markup) diff --git a/Tests/SwiftDocCTests/Indexing/IndexingTests.swift b/Tests/SwiftDocCTests/Indexing/IndexingTests.swift index 454fff4c9..13f2f0462 100644 --- a/Tests/SwiftDocCTests/Indexing/IndexingTests.swift +++ b/Tests/SwiftDocCTests/Indexing/IndexingTests.swift @@ -16,7 +16,7 @@ class IndexingTests: XCTestCase { // MARK: - Tutorial func testTutorial() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let tutorialReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) let node = try context.entity(with: tutorialReference) let tutorial = node.semantic as! Tutorial var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: tutorialReference) @@ -69,7 +69,7 @@ class IndexingTests: XCTestCase { .init(title: "Section 1", contentSection: [.contentAndMedia(content: contentSection)], stepsSection: [.paragraph(.init(inlineContent: [.text("This is a step.")]))], anchor: "section-1"), .init(title: "Section 2", contentSection: [.contentAndMedia(content: contentSection)], stepsSection: [.paragraph(.init(inlineContent: [.text("This is a step.")]))], anchor: "section-2"), ]) - let tutorialReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/TestTutorial", sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/TestTutorial", sourceLanguage: .swift) let indexingRecords = try tutorialSectionsSection.indexingRecords(onPage: tutorialReference, references: [:]) XCTAssertEqual(2, indexingRecords.count) @@ -90,7 +90,7 @@ class IndexingTests: XCTestCase { func testArticle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! TutorialArticle var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) @@ -188,7 +188,7 @@ class IndexingTests: XCTestCase { func testRootPageIndexingRecord() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! Symbol var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) @@ -221,7 +221,7 @@ class IndexingTests: XCTestCase { try updatedPlistData.write(to: plistURL) } - let articleReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: articleReference) let article = node.semantic as! Symbol var converter = RenderNodeTranslator(context: context, bundle: bundle, identifier: articleReference) diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 483c3d3d1..df8a1ed77 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -1816,7 +1816,7 @@ Root func testNormalizedNavigatorIndexIdentifier() throws { let topicReference = ResolvedTopicReference( - id: "org.swift.example", + bundleID: "org.swift.example", path: "/documentation/path/sub-path", fragment: nil, sourceLanguage: .swift @@ -1833,7 +1833,7 @@ Root ) let topicReferenceWithCapitalization = ResolvedTopicReference( - id: "org.Swift.Example", + bundleID: "org.Swift.Example", path: "/documentation/Path/subPath", fragment: nil, sourceLanguage: .swift @@ -1850,7 +1850,7 @@ Root ) let topicReferenceWithFragment = ResolvedTopicReference( - id: "org.Swift.Example", + bundleID: "org.Swift.Example", path: "/documentation/Path/subPath", fragment: "FRAGMENT", sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift index 0d64a38cd..392b5a599 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AnchorSectionTests.swift @@ -21,15 +21,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TechnologyX/Article", fragment: "Article-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -79,15 +79,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass", fragment: "Symbol-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the module page - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion @@ -137,15 +137,15 @@ class AnchorSectionTests: XCTestCase { // Verify the sub-sections of the article have been collected in the context [ - ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), - ResolvedTopicReference(id: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Section", sourceLanguage: .swift), + ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/CoolFramework", fragment: "Module-Sub-Sub-Section", sourceLanguage: .swift), ] .forEach { sectionReference in XCTAssertTrue(context.nodeAnchorSections.keys.contains(sectionReference)) } // Load the article page - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TechnologyX/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) // Extract the links from the discussion diff --git a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift index c6a494801..9c361152c 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift @@ -66,7 +66,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -113,7 +113,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let parameterSections = symbol.parametersSectionVariants @@ -156,7 +156,7 @@ class AutoCapitalizationTests: XCTestCase { XCTAssertEqual(context.problems.count, 0) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift index 312f4f0b5..485983550 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift @@ -98,7 +98,7 @@ class AutomaticCurationTests: XCTestCase { file: StaticString = #file, line: UInt = #line ) throws { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = try XCTUnwrap(translator.visit(node.semantic) as? RenderNode, file: file, line: line) @@ -130,7 +130,7 @@ class AutomaticCurationTests: XCTestCase { try sideKit.write(to: url.appendingPathComponent("documentation").appendingPathComponent("sidekit.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile the render node to flex the automatic curator let symbol = node.semantic as! Symbol @@ -180,7 +180,7 @@ class AutomaticCurationTests: XCTestCase { """.write(to: url.appendingPathComponent("documentation/sideclass.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -342,7 +342,7 @@ class AutomaticCurationTests: XCTestCase { // The first topic section do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -358,7 +358,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClassFour", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -371,7 +371,7 @@ class AutomaticCurationTests: XCTestCase { // The second topic section do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClassSix", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -383,21 +383,21 @@ class AutomaticCurationTests: XCTestCase { // The automatically curated symbols shouldn't have a See Also section do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClassEight", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClassNine", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertNil(renderNode.seeAlsoSections.first, "This symbol was automatically curated and shouldn't have a See Also section") } do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClassTen", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -424,7 +424,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the framework render node - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -437,7 +437,7 @@ class AutomaticCurationTests: XCTestCase { do { // Get the `A` render node - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/A", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed/A", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -477,7 +477,7 @@ class AutomaticCurationTests: XCTestCase { // Load the "MixedLanguageProtocol Implementations" API COllection let protocolImplementationsNode = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MixedLanguageFramework/MixedLanguageClassConformingToProtocol/MixedLanguageProtocol-Implementations", sourceLanguages: [.swift, .objectiveC] ) @@ -503,7 +503,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MixedLanguageFramework", sourceLanguages: [.swift, .objectiveC] ) @@ -577,7 +577,7 @@ class AutomaticCurationTests: XCTestCase { let frameworkDocumentationNode = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/Whatsit", sourceLanguages: [.objectiveC] ) @@ -603,7 +603,7 @@ class AutomaticCurationTests: XCTestCase { let classDocumentationNode = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/Whatsit/Whatsit", sourceLanguages: [.objectiveC] ) @@ -638,7 +638,7 @@ class AutomaticCurationTests: XCTestCase { let containerDocumentationNode = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/ThirdOrder/SomeStruct", sourceLanguages: [.swift] ) @@ -665,7 +665,7 @@ class AutomaticCurationTests: XCTestCase { let rootDocumentationNode = try context.entity( with: .init( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CxxSymbols", sourceLanguage: .objectiveC ) @@ -755,7 +755,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -809,7 +809,7 @@ class AutomaticCurationTests: XCTestCase { let protocolDocumentationNode = try context.entity( with: .init( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/ShapeKit/OverloadedProtocol", sourceLanguage: .swift)) @@ -866,7 +866,7 @@ class AutomaticCurationTests: XCTestCase { let catalogURL = try exampleDocumentation.write(inside: createTemporaryDirectory()) let (_, bundle, context) = try loadBundle(from: catalogURL) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift)) // Compile docs and verify the generated Topics section var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift index c4440251a..75f930087 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift @@ -31,7 +31,7 @@ class DocumentationContext_MixedLanguageLinkResolutionTests: XCTestCase { let resolutionResult = context.resolve( .unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(symbolPath: symbolPath))), in: ResolvedTopicReference( - id: "org.swift.MixedLanguageFramework", + bundleID: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/\(parentPath)", sourceLanguage: .swift ), diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift index 32cbada06..aab9b5b85 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+RootPageTests.swift @@ -46,7 +46,7 @@ class DocumentationContext_RootPageTests: XCTestCase { XCTAssertEqual(context.rootModules.map({ $0.url.path }), ["/documentation/ReleaseNotes"]) // Verify the root was crawled - XCTAssertEqual(context.topicGraph.edges[ResolvedTopicReference(id: "com.test.example", path: "/documentation/ReleaseNotes", sourceLanguage: .swift)]?.map({ $0.url.path }), + XCTAssertEqual(context.topicGraph.edges[ResolvedTopicReference(bundleID: "com.test.example", path: "/documentation/ReleaseNotes", sourceLanguage: .swift)]?.map({ $0.url.path }), ["/documentation/TestBundle/ReleaseNotes-1.2"]) } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index bfbc70939..9f37c3cd7 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -85,11 +85,11 @@ class DocumentationContextTests: XCTestCase { func testLoadEntity() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let identifier = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "some.other.bundle", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleID: "some.other.bundle", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift))) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/Test-Bundle/wrongIdentifier", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/Test-Bundle/wrongIdentifier", sourceLanguage: .swift))) let node = try context.entity(with: identifier) @@ -1235,7 +1235,7 @@ class DocumentationContextTests: XCTestCase { let (bundle, context) = try loadBundle(catalog: testCatalog) let renderContext = RenderContext(documentationContext: context, bundle: bundle) - let identifier = ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) let node = try context.entity(with: identifier) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -1326,15 +1326,15 @@ let expected = """ assertEqualDumps(context.dumpGraph(), expected) // Test correct symbol hierarchy in context - XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, + XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, [["doc://org.swift.docc.example/documentation/MyKit"], ["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyProtocol"]]) - XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-33vaw", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, + XCTAssertEqual(context.finitePaths(to: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-33vaw", sourceLanguage: .swift)).map { $0.map {$0.absoluteString} }, [["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyClass"], ["doc://org.swift.docc.example/documentation/MyKit", "doc://org.swift.docc.example/documentation/MyKit/MyProtocol", "doc://org.swift.docc.example/documentation/MyKit/MyClass"]]) } func createNode(in context: DocumentationContext, bundle: DocumentationBundle, parent: ResolvedTopicReference, name: String) throws -> (DocumentationNode, TopicGraph.Node) { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) let node = DocumentationNode(reference: reference, kind: .article, sourceLanguage: .swift, name: .conceptual(title: name), markup: Document(parsing: "# \(name)"), semantic: nil) let tgNode = TopicGraph.Node(reference: reference, kind: .article, source: .external, title: name) @@ -1349,7 +1349,7 @@ let expected = """ func testSortingBreadcrumbsOfEqualDistanceToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) /// /// Create nodes in alphabetical order @@ -1383,7 +1383,7 @@ let expected = """ func testSortingBreadcrumbsOfDifferentDistancesToRoot() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let mykit = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let mykit = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let tgMykitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(mykit)) /// @@ -1431,7 +1431,7 @@ let expected = """ }) // Verify the node is a child of the module node when the graph is loaded. - let sideClassReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let sideClassReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) let parents = context.parents(of: sideClassReference) XCTAssertEqual(parents.map {$0.path}, ["/documentation/SideKit"]) } @@ -1452,7 +1452,7 @@ let expected = """ } // Get a node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) // Get the breadcrumbs as paths let paths = context.finitePaths(to: node.reference).sorted { (path1, path2) -> Bool in @@ -1513,8 +1513,8 @@ let expected = """ } // Verify the non-overload collisions were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.enum.case", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.var", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.enum.case", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-swift.var", sourceLanguage: .swift))) } func testModuleLanguageFallsBackToSwiftIfItHasNoSymbols() throws { @@ -1642,9 +1642,9 @@ let expected = """ } // Verify the non-overload collisions were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/tEst-9053a", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-959hd", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/tEst-9053a", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/test-959hd", sourceLanguage: .swift))) } func testUnknownSymbolKind() throws { @@ -1656,7 +1656,7 @@ let expected = """ } // Get a function node, verify its kind is unknown - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) XCTAssertEqual(node.kind, .unknown) } @@ -1840,7 +1840,7 @@ let expected = """ let problems = context.problems XCTAssertEqual(problems.count, 0, "Unexpected problems: \(problems.map(\.diagnostic.summary).sorted())") - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let entity = try context.entity(with: moduleReference) let moduleSymbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -2023,9 +2023,9 @@ let expected = """ XCTAssert(symbolGraphProblems.isEmpty, "There shouldn't be any errors or warnings in the symbol graphs") // Verify the non-overload collisions form different symbol graph files were resolved - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class/path", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/sideClass-swift.var", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass-swift.class/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/sideClass-swift.var", sourceLanguage: .swift))) } func testUnresolvedSidecarDiagnostics() throws { @@ -2097,7 +2097,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/Symbol_Name", sourceLanguage: .swift) let node = try context.entity(with: reference) XCTAssertEqual((node.semantic as? Symbol)?.abstract?.plainText, "Extend a symbol with a space in its name.") @@ -2147,7 +2147,7 @@ let expected = """ XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/OldSymbol", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -2156,7 +2156,7 @@ let expected = """ } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -2312,17 +2312,17 @@ let expected = """ } // Test that collision symbol reference was updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum", sourceLanguage: .swift))) // Test that collision symbol child reference was updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/path", sourceLanguage: .swift))) // Test that nested collisions were updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum", sourceLanguage: .swift))) - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property", sourceLanguage: .swift))) // Test that child of nested collision is updated - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum/path", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/Test-swift.enum/NestedEnum-swift.enum/path", sourceLanguage: .swift))) // Verify that the symbol index has been updated with the rewritten collision-corrected symbol paths XCTAssertEqual(context.documentationCache.reference(symbolID: "s:7SideKit0A5ClassC10testnEE")?.path, "/documentation/SideKit/SideClass/Test-swift.enum/nestedEnum-swift.property") @@ -2445,14 +2445,14 @@ let expected = """ } // Verify that the Tertiary framework has no symbol in the graph - XCTAssertNotNil(try? context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))) - XCTAssertNil(try? context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Tertiary", sourceLanguage: .swift))) + XCTAssertNotNil(try? context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift))) + XCTAssertNil(try? context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Tertiary", sourceLanguage: .swift))) } func testDeclarationTokenKinds() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFunc = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let myFunc = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) // Symbol graph declaration tokens, including more esoteric kinds like internalParam, externalParam, and unknown kinds. let tokens = (myFunc.symbol!.mixins[SymbolGraph.Symbol.DeclarationFragments.mixinKey] as? SymbolGraph.Symbol.DeclarationFragments)? @@ -2600,7 +2600,7 @@ let expected = """ func testNavigatorTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func renderNodeForPath(path: String) throws -> (DocumentationNode, RenderNode) { - let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2655,7 +2655,7 @@ let expected = """ let (_, _, context) = try loadBundle(from: catalogURL) let referenceForPath: (String) -> ResolvedTopicReference = { path in - return ResolvedTopicReference(id: "com.test.collisions", path: "/documentation" + path, sourceLanguage: .swift) + return ResolvedTopicReference(bundleID: "com.test.collisions", path: "/documentation" + path, sourceLanguage: .swift) } // Verify that: @@ -2722,13 +2722,13 @@ let expected = """ let beforeCount = try XCTUnwrap(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Verify a given identifier exists in the pool by creating it and verifying it wasn't added to the pool - _ = ResolvedTopicReference(id: bundleID, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) // Verify create the reference above did not add to the cache XCTAssertEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) // Create a new reference for the same bundle that was not loaded with the context - _ = ResolvedTopicReference(id: bundleID, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/tutorials/Test-Bundle/TestTutorial/\(#function)", sourceLanguage: .swift) // Verify creating a new reference added to the ones loaded with the context XCTAssertNotEqual(beforeCount, ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) @@ -2742,7 +2742,7 @@ let expected = """ // Get the SideKit/SideClass/init() node and verify it has an abstract and no discussion. // We're verifying that the metadata directive between the title and the abstract didn't cause // the content to overflow into the discussion. - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) let markupModel = DocumentationMarkup(markup: node.markup) XCTAssertNotNil(markupModel.abstractSection) @@ -2772,7 +2772,7 @@ let expected = """ func testCreatingAnArticleNode() throws { // Create documentation node from markup - let reference = ResolvedTopicReference(id: "com.testbundle", path: "/documentation/NewArticle", fragment: nil, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "com.testbundle", path: "/documentation/NewArticle", fragment: nil, sourceLanguage: .swift) let source = """ # New Article @@ -2791,7 +2791,7 @@ let expected = """ let (bundle, context) = try testBundleAndContext(named: "TestBundle") // Verify task group ranges are persisted for symbol docs - let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let symbol = try XCTUnwrap((try? context.entity(with: symbolReference))?.semantic as? Symbol) let symbolTopics = try XCTUnwrap(symbol.topics) symbolTopics.originalLinkRangesByGroup.forEach { group in @@ -2799,7 +2799,7 @@ let expected = """ } // Verify task group ranges are persisted for articles - let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let article = try XCTUnwrap((try? context.entity(with: articleReference))?.semantic as? Article) let articleTopics = try XCTUnwrap(article.topics) articleTopics.originalLinkRangesByGroup.forEach { group in @@ -3362,7 +3362,7 @@ let expected = """ "'swiftOnlyMemberName' doesn't exist at '/ModuleName/ObjectiveCName'", ]) - let reference = ResolvedTopicReference(id: "unit-test", path: "/documentation/ModuleName/SwiftName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "unit-test", path: "/documentation/ModuleName/SwiftName", sourceLanguage: .swift) let entity = try context.entity(with: reference) let symbol = try XCTUnwrap(entity.semantic as? Symbol) let taskGroups = try XCTUnwrap(symbol.topics).taskGroups @@ -3471,10 +3471,10 @@ let expected = """ """.write(to: url.appendingPathComponent("fifthTestMember.md"), atomically: true, encoding: .utf8) } - let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ShapeKit/NewArticle", sourceLanguage: .swift) // Fetch the "OverloadedParentStruct" node - let reference1 = ResolvedTopicReference(id: bundle.id, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ShapeKit/OverloadedParentStruct-1jr3p", sourceLanguage: .swift) let node1 = try context.entity(with: reference1) let symbol1 = try XCTUnwrap(node1.semantic as? Symbol) @@ -3487,7 +3487,7 @@ let expected = """ XCTAssertTrue(tgNode1.contains(articleReference)) // Fetch the "fifthTestMember" node - let reference2 = ResolvedTopicReference(id: bundle.id, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) + let reference2 = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/\(fifthTestMemberPath)", sourceLanguage: .swift) let node2 = try context.entity(with: reference2) let symbol2 = try XCTUnwrap(node2.semantic as? Symbol) @@ -3570,7 +3570,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3579,7 +3579,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3588,7 +3588,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3597,7 +3597,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3606,7 +3606,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3681,7 +3681,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/first", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3690,7 +3690,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3699,7 +3699,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3708,7 +3708,7 @@ let expected = """ do { // The resolved reference needs the language info alongside the symbol kind info. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3742,7 +3742,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3751,7 +3751,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3777,7 +3777,7 @@ let expected = """ do { // The resolved reference needs more disambiguation than the documentation extension link did. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Something", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Something", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3885,7 +3885,7 @@ let expected = """ let identifiers = context.problems.map(\.diagnostic.identifier) XCTAssertFalse(identifiers.contains(where: { $0 == "org.swift.docc.ArticleUncurated" })) - let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNil(article.topics) @@ -3922,7 +3922,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) XCTAssertNotNil(article.topics) @@ -3965,7 +3965,7 @@ let expected = """ ]).write(inside: tempURL) let (_, bundle, context) = try loadBundle(from: bundleURL) - let rootReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) + let rootReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Module", sourceLanguage: .swift) let docNode = try context.entity(with: rootReference) let article = try XCTUnwrap(docNode.semantic as? Article) @@ -3993,7 +3993,7 @@ let expected = """ .replacingOccurrences(of: " - ", with: " - ") .write(to: myKitURL, atomically: true, encoding: .utf8) } - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) // Try resolving the new resolvable node switch context.resolve(.unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc:resolvable-article")!)), in: moduleReference) { @@ -4147,12 +4147,12 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Resolve from various locations in the bundle for parent in [bundle.rootReference, bundle.documentationRootReference, bundle.tutorialTableOfContentsContainer] { @@ -4184,14 +4184,14 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the context contains the conflicting topic names // Article - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift)]) // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift)]) let unresolved = TopicReference.unresolved(.init(topicURL: try XCTUnwrap(ValidatedURL(parsingExact: "doc:Test")))) - let expected = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let expected = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) let symbolReference = try XCTUnwrap(context.documentationCache.reference(symbolID: "s:12Minimal_docs4TestV")) @@ -4244,9 +4244,9 @@ let expected = """ // Load the bundle let (_, bundle, context) = try loadBundle(from: tempFolderURL) - let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) - let articleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let articleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/Test", sourceLanguage: .swift) // Verify we resolve/not resolve non-symbols when calling directly context.resolve(...) // with an explicit preference. @@ -4272,7 +4272,7 @@ let expected = """ // Verify the context contains the conflicting topic names // Tutorial - XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) + XCTAssertNotNil(context.documentationCache[ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/Test", sourceLanguage: .swift)]) // Symbol XCTAssertNotNil(context.documentationCache[symbolReference]) @@ -4315,8 +4315,8 @@ let expected = """ let (_, bundle, context) = try loadBundle(from: tempFolderURL) // Verify the module and symbol node kinds. - let symbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) XCTAssertEqual(context.topicGraph.nodeWithReference(symbolReference)?.kind, .structure) XCTAssertEqual(context.topicGraph.nodeWithReference(moduleReference)?.kind, .module) @@ -4443,7 +4443,7 @@ let expected = """ XCTAssertEqual( context.documentationExtensionURL( for: ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift @@ -4461,7 +4461,7 @@ let expected = """ XCTAssertNil( context.documentationExtensionURL( for: ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/tutorials/TestOverview", fragment: nil, sourceLanguage: .swift @@ -4686,7 +4686,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) XCTAssertEqual( context.topicGraph.reverseEdgesGraph.cycles(from: reference).map { $0.map(\.lastPathComponent) }, @@ -4771,7 +4771,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { var seenIndices = Set() @@ -4859,7 +4859,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) for kindID in overloadableKindIDs { switch context.resolve(.unresolved(.init(topicURL: .init(symbolPath: "SymbolName-\(kindID.identifier)"))), in: moduleReference, fromSymbolLink: true) { @@ -4991,7 +4991,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5068,7 +5068,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5143,7 +5143,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5213,7 +5213,7 @@ let expected = """ ]) ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift index 52b8d6788..e078e6e2f 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift @@ -31,7 +31,7 @@ class DocumentationCuratorTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") var crawler = DocumentationCurator.init(in: context, bundle: bundle) - let mykit = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + let mykit = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) var symbolsWithCustomCuration = [ResolvedTopicReference]() var curatedRelationships = [ParentChild]() @@ -98,7 +98,7 @@ class DocumentationCuratorTests: XCTestCase { let extensionFile = tempCatalogURL.appendingPathComponent("documentation/myfunction.md") var crawler = DocumentationCurator(in: context, bundle: bundle) - let mykit = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) + let mykit = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) XCTAssertNoThrow(try crawler.crawlChildren(of: mykit.reference, prepareForCuration: { _ in }, relateNodes: { _, _ in })) @@ -285,7 +285,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in module parent do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -293,7 +293,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in self do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -301,7 +301,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve top-level symbol in a child do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass") } @@ -309,7 +309,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve child in its parent do { let symbolLink = SymbolLink(destination: "myFunction()") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/MyClass/myFunction()") } @@ -317,7 +317,7 @@ class DocumentationCuratorTests: XCTestCase { // Do not resolve when not found do { let symbolLink = SymbolLink(destination: "myFunction") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let reference = crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent) XCTAssertEqual(reference?.absoluteString, nil) } @@ -325,7 +325,7 @@ class DocumentationCuratorTests: XCTestCase { // Fail to resolve across modules do { let symbolLink = SymbolLink(destination: "MyClass") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) XCTAssertNil(crawler.referenceFromSymbolLink(link: symbolLink, resolved: parent)) } } @@ -338,7 +338,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve and curate an article in module root (absolute link) do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -352,7 +352,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate an article in module root (relative link) do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -366,7 +366,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate article in the module root from within a child symbol do { let link = Link(destination: "doc:article") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) guard let reference = crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot) else { XCTFail("Did not resolve reference from link") return @@ -380,7 +380,7 @@ class DocumentationCuratorTests: XCTestCase { // Resolve/curate absolute link from a different module parent do { let link = Link(destination: "doc:documentation/Test-Bundle/article") - let parent = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) XCTAssertNotNil(crawler.referenceFromLink(link: link, resolved: parent, source: sourceRoot)) } } @@ -427,7 +427,7 @@ class DocumentationCuratorTests: XCTestCase { } var crawler = DocumentationCurator.init(in: context, bundle: bundle) - let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift) try crawler.crawlChildren(of: reference, prepareForCuration: {_ in }) { (_, _) in } @@ -482,7 +482,7 @@ class DocumentationCuratorTests: XCTestCase { func testMixedManualAndAutomaticCuration() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", sourceLanguage: .swift) let entity = try context.entity(with: reference) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -497,14 +497,14 @@ class DocumentationCuratorTests: XCTestCase { // Verify that the ONLY curation for `TopClass/name` is the manual curation under `MyArticle` // and the automatic curation under `TopClass` is not present. - let nameReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) + let nameReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed/TopClass/name", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: nameReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], ]) // Verify that the BOTH manual curations for `TopClass/age` are preserved // even if one of the manual curations overlaps with the inheritance edge from the symbol graph. - let ageReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) + let ageReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed/TopClass/age", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: ageReference).map({ $0.map(\.path) }), [ ["/documentation/TestBed", "/documentation/TestBed/TopClass"], ["/documentation/TestBed", "/documentation/TestBed/TopClass", "/documentation/TestBed/TopClass/NestedEnum", "/documentation/TestBed/TopClass/NestedEnum/SecondLevelNesting", "/documentation/TestBed/MyArticle"], @@ -516,7 +516,7 @@ class DocumentationCuratorTests: XCTestCase { func testMultipleManualCurationIsPreserved() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/TestBed/DoublyManuallyCuratedClass/type()", sourceLanguage: .swift) XCTAssertEqual(context.finitePaths(to: reference).map({ $0.map({ $0.path }) }), [ [ diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift index d711ee693..59361dfc0 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift @@ -798,7 +798,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { // Check the relationships of 'SomeClass' do { - let reference = ResolvedTopicReference(id: mainBundle.id, path: "/documentation/Main/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: mainBundle.id, path: "/documentation/Main/SomeClass", sourceLanguage: .swift) let entity = try mainContext.entity(with: reference) let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity)) @@ -822,7 +822,7 @@ class ExternalPathHierarchyResolverTests: XCTestCase { // Check the declaration of 'someFunction' do { - let reference = ResolvedTopicReference(id: mainBundle.id, path: "/documentation/Main/SomeClass/someFunction(parameter:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: mainBundle.id, path: "/documentation/Main/SomeClass/someFunction(parameter:)", sourceLanguage: .swift) let entity = try mainContext.entity(with: reference) let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity)) diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 3becc25c6..a45b26ae2 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -30,11 +30,11 @@ class ExternalReferenceResolverTests: XCTestCase { if let path = reference.url?.path { resolvedExternalPaths.append(path) } - return .success(ResolvedTopicReference(id: bundleID, path: expectedReferencePath, fragment: expectedFragment, sourceLanguage: resolvedEntityLanguage)) + return .success(ResolvedTopicReference(bundleID: bundleID, path: expectedReferencePath, fragment: expectedFragment, sourceLanguage: resolvedEntityLanguage)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { - guard reference.id == bundleID else { + guard reference.bundleID == bundleID else { fatalError("It is a programming mistake to retrieve an entity for a reference that the external resolver didn't resolve.") } @@ -69,14 +69,14 @@ class ExternalReferenceResolverTests: XCTestCase { } let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://com.external.testbundle/article")!) - let parent = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyClass", sourceLanguage: .swift) + let parent = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyClass", sourceLanguage: .swift) guard case let .success(resolved) = context.resolve(.unresolved(unresolved), in: parent) else { XCTFail("Couldn't resolve \(unresolved)") return } - XCTAssertEqual("com.external.testbundle", resolved.id) + XCTAssertEqual("com.external.testbundle", resolved.bundleID) XCTAssertEqual("/externally/resolved/path", resolved.path) let expectedURL = URL(string: "doc://com.external.testbundle/externally/resolved/path") @@ -120,7 +120,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) let sideClassReference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift ) @@ -221,9 +221,9 @@ class ExternalReferenceResolverTests: XCTestCase { func testLoadEntityForExternalReference() throws { let (_, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: ["com.external.testbundle" : TestExternalReferenceResolver()]) - let identifier = ResolvedTopicReference(id: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: "some.other.bundle", path: identifier.path, sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleID: "some.other.bundle", path: identifier.path, sourceLanguage: .swift))) XCTAssertThrowsError(try context.entity(with: identifier)) } @@ -254,7 +254,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let fileURL = context.documentURL(for: node.reference) else { XCTFail("Unable to find the file for \(node.reference.path)") @@ -308,7 +308,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -353,7 +353,7 @@ class ExternalReferenceResolverTests: XCTestCase { let (bundle, context) = try loadBundle(catalog: tempFolder, configuration: configuration) let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/article", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -400,7 +400,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -499,7 +499,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SomeSample", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeSample", sourceLanguage: .swift)) let renderNode = try converter.convert(node) @@ -612,7 +612,7 @@ class ExternalReferenceResolverTests: XCTestCase { } // Get MyKit symbol - let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let taskGroupLinks = try XCTUnwrap((entity.semantic as? Symbol)?.topics?.taskGroups.first?.links.compactMap({ $0.destination })) // Verify the task group links have been resolved and are still present in the link list. @@ -644,7 +644,7 @@ class ExternalReferenceResolverTests: XCTestCase { }) // Verify the external symbol is included in external cache - let reference = ResolvedTopicReference(id: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) XCTAssertNil(context.documentationCache[reference]) XCTAssertNotNil(context.externalCache[reference]) @@ -690,7 +690,7 @@ class ExternalReferenceResolverTests: XCTestCase { } } // Note that this resolved reference doesn't have the same path as the unresolved reference. - return .success(.init(id: "com.external.testbundle", path: "/resolved", sourceLanguage: .swift)) + return .success(.init(bundleID: "com.external.testbundle", path: "/resolved", sourceLanguage: .swift)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { @@ -757,18 +757,18 @@ class ExternalReferenceResolverTests: XCTestCase { // Expected successful externally resolved reference. XCTAssertEqual( context.externallyResolvedLinks[ValidatedURL(parsingExact: "doc://com.external.testbundle/resolvable")!], - TopicReferenceResolutionResult.success(ResolvedTopicReference(id: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) + TopicReferenceResolutionResult.success(ResolvedTopicReference(bundleID: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) ) XCTAssertEqual( context.externallyResolvedLinks[ValidatedURL(parsingExact: "doc://com.external.testbundle/resolved")!], - TopicReferenceResolutionResult.success(ResolvedTopicReference(id: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) + TopicReferenceResolutionResult.success(ResolvedTopicReference(bundleID: "com.external.testbundle", path: "/resolved", fragment: nil, sourceLanguage: .swift)) ) XCTAssert(context.problems.contains(where: { $0.diagnostic.summary.contains("Unit test: External resolve error.")}), "The external reference resolver error message is included in that problem's error summary.") // Get MyKit symbol - let entity = try context.entity(with: .init(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) + let entity = try context.entity(with: .init(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let renderNode = try converter.convert(entity) @@ -810,7 +810,7 @@ class ExternalReferenceResolverTests: XCTestCase { .write(to: myClassMDURL, atomically: true, encoding: .utf8) }) - let myClassRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let myClassRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let documentationNode = try context.entity(with: myClassRef) // Verify the external link was resolved in markup. @@ -891,7 +891,7 @@ class ExternalReferenceResolverTests: XCTestCase { } let converter = DocumentationNodeConverter(bundle: bundle, context: context) let mixedLanguageFrameworkReference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MixedLanguageFramework", sourceLanguage: .swift ) @@ -967,7 +967,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Symbol)?.deprecatedSummary) @@ -976,7 +976,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let node = try context.entity(with: reference) let deprecatedSection = try XCTUnwrap((node.semantic as? Article)?.deprecationSummary) @@ -1037,7 +1037,7 @@ class ExternalReferenceResolverTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/First", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/First", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1051,7 +1051,7 @@ class ExternalReferenceResolverTests: XCTestCase { } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Second", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Second", sourceLanguage: .swift) let node = try context.entity(with: reference) let rendered = try converter.convert(node) @@ -1175,7 +1175,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SymbolName", sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. @@ -1214,7 +1214,7 @@ class ExternalReferenceResolverTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))", file: file, line: line) // Load the DocumentationNode for the artist dictionary keys symbol. - let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) // Get the semantic symbol and the variants of the dictionary keys section. diff --git a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift index a0c675580..a3598257b 100644 --- a/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/NodeTagsTests.swift @@ -27,7 +27,7 @@ class NodeTagsTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL) // Verify that `Test` is marked as SPI. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/Test", sourceLanguage: .swift) let node = try XCTUnwrap(context.entity(with: reference)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssertTrue(symbol.isSPI) @@ -39,7 +39,7 @@ class NodeTagsTests: XCTestCase { XCTAssertEqual(renderNode.metadata.tags, [.spi]) // Verify that the link to the node contains the SPI tag. - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs", sourceLanguage: .swift) let moduleNode = try XCTUnwrap(context.entity(with: moduleReference)) let moduleSymbol = try XCTUnwrap(moduleNode.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift index adebeb192..422f2e285 100644 --- a/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/NodeURLGeneratorTests.swift @@ -50,27 +50,27 @@ class NodeURLGeneratorTests: XCTestCase { let baseURL = URL(string: "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/")! let generator = NodeURLGenerator(baseURL: baseURL) - let basicIdentifier = ResolvedTopicReference(id: "com.example.testbundle", + let basicIdentifier = ResolvedTopicReference(bundleID: "com.example.testbundle", path: "/folder/class/symbol", fragment: nil, sourceLanguage: .swift) XCTAssertEqual(generator.urlForReference(basicIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/symbol") - let symbolIdentifier = ResolvedTopicReference(id: "com.example.testbundle", + let symbolIdentifier = ResolvedTopicReference(bundleID: "com.example.testbundle", path: "/folder/class/.==", fragment: nil, sourceLanguage: .swift) XCTAssertEqual(generator.urlForReference(symbolIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/'.==") - let privateIdentifier = ResolvedTopicReference(id: "com.example.testbundle", + let privateIdentifier = ResolvedTopicReference(bundleID: "com.example.testbundle", path: "/folder/class/_privateMethod", fragment: nil, sourceLanguage: .objectiveC) XCTAssertEqual(generator.urlForReference(privateIdentifier).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/_privateMethod") XCTAssertEqual(generator.urlForReference(privateIdentifier, lowercased: true).absoluteString, "file:///path/to/bundle/_testbundle-ctlj/products/documentation.builtbundle/com.example.testbundle/data/folder/class/_privatemethod") - let classIdentifier = ResolvedTopicReference(id: "com.example.testbundle", + let classIdentifier = ResolvedTopicReference(bundleID: "com.example.testbundle", path: "/folder/_privateclass/_privatesubclass", fragment: nil, sourceLanguage: .objectiveC) diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index 52a84ef6d..3e6bde73f 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -1112,7 +1112,7 @@ class PathHierarchyTests: XCTestCase { let tree = try XCTUnwrap(linkResolver.pathHierarchy) // Test finding the parent via the `fromTopicReference` integration shim. - let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)]! + let parentID = linkResolver.resolvedReferenceMap[ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)]! XCTAssertNotNil(parentID) XCTAssertEqual(try tree.findSymbol(path: "globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") XCTAssertEqual(try tree.findSymbol(path: "MyKit/globalFunction(_:considering:)", parent: parentID).identifier.precise, "s:5MyKit14globalFunction_11consideringy10Foundation4DataV_SitF") diff --git a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift index 791a897f9..96fe55b4a 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift @@ -18,19 +18,19 @@ class PresentationURLGeneratorTests: XCTestCase { let generator = PresentationURLGenerator(context: context, baseURL: URL(string: "https://host:1024/webPrefix")!) // Test resolved tutorial reference - let reference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(reference).absoluteString, "https://host:1024/webPrefix/tutorials/test-bundle/testtutorial") // Test resolved symbol reference - let symbol = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let symbol = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(symbol).absoluteString, "https://host:1024/webPrefix/documentation/mykit/myclass") // Test root - let root = ResolvedTopicReference(id: bundle.id, path: "/", sourceLanguage: .swift) + let root = ResolvedTopicReference(bundleID: bundle.id, path: "/", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(root).absoluteString, "https://host:1024/webPrefix/documentation") // Fragment - let fragment = ResolvedTopicReference(id: bundle.id, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) + let fragment = ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: "test URL! FRAGMENT", sourceLanguage: .swift) XCTAssertEqual(generator.presentationURLForReference(fragment).absoluteString, "https://host:1024/webPrefix/path#test-URL-FRAGMENT") } } diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index fca0bb31e..1cef3e3a1 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -100,7 +100,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -126,7 +126,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -152,7 +152,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -178,7 +178,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -203,7 +203,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -229,7 +229,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -377,7 +377,7 @@ class ReferenceResolverTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -409,7 +409,7 @@ class ReferenceResolverTests: XCTestCase { func testCuratedExtensionRemovesEmptyPage() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithSingleExtension") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -421,7 +421,7 @@ class ReferenceResolverTests: XCTestCase { // Make sure that the symbol added in the extension is still present in the topic graph, // even though its synthetic "extended symbol" parents are not - XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) + XCTAssertNoThrow(try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array/asdf", sourceLanguage: .swift))) } func testCuratedExtensionWithDanglingReference() throws { @@ -445,15 +445,15 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) // Load the RenderNode for the root article and make sure that the `Swift/Array` symbol link // is not rendered as a link - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -485,10 +485,10 @@ class ReferenceResolverTests: XCTestCase { XCTAssertEqual(replacement.replacement, "`Swift/Array`") // Also make sure that the extension pages are still gone - let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssertFalse(context.knownPages.contains(where: { $0 == extendedStructure })) } @@ -514,17 +514,17 @@ class ReferenceResolverTests: XCTestCase { XCTAssertFalse(context.problems.contains(where: { $0.diagnostic.identifier == "org.swift.docc.removedExtensionLinkDestination" || $0.diagnostic.identifier == "org.swift.docc.unresolvedTopicReference" })) // Because the `Swift/Array` extension has an extension article, the pages should not be marked as virtual - let extendedModule = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) + let extendedModule = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedModule })) - let extendedStructure = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) + let extendedStructure = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithSingleExtension/Swift/Array", sourceLanguage: .swift) XCTAssert(context.knownPages.contains(where: { $0 == extendedStructure })) } func testCuratedExtensionWithAdditionalConformance() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithConformanceAndExtension") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithConformanceAndExtension/MyProtocol", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -540,7 +540,7 @@ class ReferenceResolverTests: XCTestCase { func testExtensionWithEmptyDeclarationFragments() throws { let (bundle, context) = try testBundleAndContext(named: "ModuleWithEmptyDeclarationFragments") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleWithEmptyDeclarationFragments", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -738,8 +738,8 @@ class ReferenceResolverTests: XCTestCase { } func testEmitsDiagnosticsForEachDocumentationChunk() throws { - let moduleReference = ResolvedTopicReference(id: "com.example.test", path: "/documentation/ModuleName", sourceLanguage: .swift) - let reference = ResolvedTopicReference(id: "com.example.test", path: "/documentation/ModuleName/Something", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: "com.example.test", path: "/documentation/ModuleName", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "com.example.test", path: "/documentation/ModuleName/Something", sourceLanguage: .swift) let inSourceComment = """ Some description of this class diff --git a/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift b/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift index f8865b7f8..f1a9c5a68 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ResolvedTopicReferenceTests.swift @@ -16,7 +16,7 @@ import XCTest class ResolvedTopicReferenceTests: XCTestCase { func testReferenceURL() { let firstTopicReference = ResolvedTopicReference( - id: "bundleID", + bundleID: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift @@ -24,7 +24,7 @@ class ResolvedTopicReferenceTests: XCTestCase { XCTAssertEqual(firstTopicReference.absoluteString, "doc://bundleID/path/sub-path#fragment") let secondTopicReference = ResolvedTopicReference( - id: "new-bundleID", + bundleID: "new-bundleID", path: "/new-path/sub-path", fragment: firstTopicReference.fragment, sourceLanguage: firstTopicReference.sourceLanguage @@ -41,7 +41,7 @@ class ResolvedTopicReferenceTests: XCTestCase { func testAppendingReferenceWithEmptyPath() { // An empty path do { - let resolvedOriginal = ResolvedTopicReference(id: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) + let resolvedOriginal = ResolvedTopicReference(bundleID: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) let unresolved = UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://host-name")!) XCTAssert(unresolved.path.isEmpty) @@ -52,7 +52,7 @@ class ResolvedTopicReferenceTests: XCTestCase { // A path with no url path allowed characters do { - let resolvedOriginal = ResolvedTopicReference(id: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) + let resolvedOriginal = ResolvedTopicReference(bundleID: "bundleID", path: "/path/sub-path", fragment: "fragment", sourceLanguage: .swift) var components = URLComponents() components.scheme = "doc" @@ -69,7 +69,7 @@ class ResolvedTopicReferenceTests: XCTestCase { func testStorageIsConcurrentlyAccessible() throws { let topicReference = ResolvedTopicReference( - id: "com.apple.example", + bundleID: "com.apple.example", path: "/documentation/path/sub-path", fragment: nil, sourceLanguage: .swift diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index a0836bd33..52c1ff8c1 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -24,10 +24,10 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let targetRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/B", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let targetRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/B", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: sourceType, mixins: [:]) let targetSymbol = SymbolGraph.Symbol(identifier: targetIdentifier, names: SymbolGraph.Symbol.Names(title: "B", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "B"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: targetType, mixins: [:]) @@ -130,8 +130,8 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: SymbolGraph.Symbol.Kind(parsedIdentifier: .class, displayName: "Class"), mixins: [:]) diff --git a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift index c22480d22..cc50b13ab 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift @@ -52,13 +52,13 @@ class TestMultiResultExternalReferenceResolver: ExternalDocumentationSource { let entity = entityInfo(path: path) return .success( - ResolvedTopicReference(id: bundleID, path: entity.referencePath,fragment: entity.fragment,sourceLanguage: entity.language) + ResolvedTopicReference(bundleID: bundleID, path: entity.referencePath,fragment: entity.fragment,sourceLanguage: entity.language) ) } } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { - guard reference.id == bundleID else { + guard reference.bundleID == bundleID else { fatalError("It is a programming mistake to retrieve an entity for a reference that the external resolver didn't resolve.") } return makeNode(for: entityInfo(path: reference.path), reference: reference) diff --git a/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift b/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift index 13f51ad2a..1895409ca 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TopicGraphTests.swift @@ -16,7 +16,7 @@ class TopicGraphTests: XCTestCase { /// Returns a ``ResolvedTopicReference`` with the given title, with a phony source language, kind, and source. These are not for testing specific relationships, only abstract graph connectivity. static func testNodeWithTitle(_ title: String) -> TopicGraph.Node { let urlSafeTitle = title.replacingOccurrences(of: " ", with: "_") - let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(urlSafeTitle)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(urlSafeTitle)", sourceLanguage: .swift) return TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: URL(fileURLWithPath: "/path/to/\(urlSafeTitle)")), title: title) } diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 03bc09d5c..ef1b6a095 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -98,7 +98,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestBundle/Tutorial", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) @@ -154,7 +154,7 @@ class ExternalLinkableTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -198,7 +198,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -239,7 +239,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -274,7 +274,7 @@ class ExternalLinkableTests: XCTestCase { } do { - let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -331,7 +331,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { - let symbolReference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) var summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -436,7 +436,7 @@ class ExternalLinkableTests: XCTestCase { // Check a symbol that's represented as a class in both Swift and Objective-C do { - let symbolReference = ResolvedTopicReference(id: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -495,7 +495,7 @@ class ExternalLinkableTests: XCTestCase { // Check the Swift version of a symbol that's represented differently in different languages do { - let symbolReference = ResolvedTopicReference(id: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)", sourceLanguage: .swift) + let symbolReference = ResolvedTopicReference(bundleID: "org.swift.MixedLanguageFramework", path: "/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)", sourceLanguage: .swift) let node = try context.entity(with: symbolReference) let renderNode = try converter.convert(node) let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] @@ -627,7 +627,7 @@ class ExternalLinkableTests: XCTestCase { let decoded = try JSONDecoder().decode(LinkDestinationSummary.self, from: legacyData) - XCTAssertEqual(decoded.referenceURL, ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/ClassName", sourceLanguage: .swift).url) + XCTAssertEqual(decoded.referenceURL, ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/ClassName", sourceLanguage: .swift).url) XCTAssertEqual(decoded.platforms?.count, 1) XCTAssertEqual(decoded.platforms?.first?.name, "PlatformName") XCTAssertEqual(decoded.platforms?.first?.introduced, "1.0") @@ -727,7 +727,7 @@ class ExternalLinkableTests: XCTestCase { let converter = DocumentationNodeConverter(bundle: bundle, context: context) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyModule/MyClass/myFunc()", sourceLanguage: .swift)) let renderNode = try converter.convert(node) let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode) diff --git a/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift b/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift index 16cb6bd05..9b371d23e 100644 --- a/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/DocumentationNodeTests.swift @@ -31,7 +31,7 @@ class DocumentationNodeTests: XCTestCase { let article = Article(markup: Document(parsing: articleSource, options: []), metadata: nil, redirects: nil, options: [:]) let node = try DocumentationNode( - reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), + reference: ResolvedTopicReference(bundleID: "org.swift.docc", path: "/blah", sourceLanguage: .swift), article: article ) XCTAssertEqual(node.anchorSections.count, 5) diff --git a/Tests/SwiftDocCTests/Model/IdentifierTests.swift b/Tests/SwiftDocCTests/Model/IdentifierTests.swift index d172513f8..c83c3c564 100644 --- a/Tests/SwiftDocCTests/Model/IdentifierTests.swift +++ b/Tests/SwiftDocCTests/Model/IdentifierTests.swift @@ -73,15 +73,15 @@ class IdentifierTests: XCTestCase { XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") // Add the same reference repeatedly - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should still only have one cached reference because the same reference was created repeatedly") // Add another reference - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/other-page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/other-page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 2, "Should have cached another reference because two different references with this bundle identifier has been created") // Purge and repeat @@ -91,7 +91,7 @@ class IdentifierTests: XCTestCase { ResolvedTopicReference.enableReferenceCaching(for: bundleID) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 0, "Should have an empty cache after enabling reference caching for this bundle") - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertEqual(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), 1, "Should have an cached one reference because a reference with this bundle identifier was created") } @@ -99,21 +99,21 @@ class IdentifierTests: XCTestCase { let bundleID: DocumentationBundle.Identifier = #function XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "References for this bundle shouldn't exist because caching is not enabled by default") - _ = ResolvedTopicReference(id: bundleID, path: "/path/to/page", sourceLanguage: .swift) + _ = ResolvedTopicReference(bundleID: bundleID, path: "/path/to/page", sourceLanguage: .swift) XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID), "After creating a reference in this bundle, references still shouldn't exist because caching is not enabled by default") } func testReferenceInitialPathComponents() { - let ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) + let ref1 = ResolvedTopicReference(bundleID: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.pathComponents, ["/"]) - let ref2 = ResolvedTopicReference(id: "bundle", path: "/MyClass", sourceLanguage: .swift) + let ref2 = ResolvedTopicReference(bundleID: "bundle", path: "/MyClass", sourceLanguage: .swift) XCTAssertEqual(ref2.pathComponents, ["/", "MyClass"]) - let ref3 = ResolvedTopicReference(id: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) + let ref3 = ResolvedTopicReference(bundleID: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) XCTAssertEqual(ref3.pathComponents, ["/", "MyClass", "myFunction"]) } func testReferenceUpdatedPathComponents() { - var ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) + var ref1 = ResolvedTopicReference(bundleID: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.pathComponents, ["/"]) ref1 = ref1.appendingPath("MyClass") XCTAssertEqual(ref1.pathComponents, ["/", "MyClass"]) @@ -124,16 +124,16 @@ class IdentifierTests: XCTestCase { } func testReferenceInitialAbsoluteString() { - let ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) + let ref1 = ResolvedTopicReference(bundleID: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.absoluteString, "doc://bundle/") - let ref2 = ResolvedTopicReference(id: "bundle", path: "/MyClass", sourceLanguage: .swift) + let ref2 = ResolvedTopicReference(bundleID: "bundle", path: "/MyClass", sourceLanguage: .swift) XCTAssertEqual(ref2.absoluteString, "doc://bundle/MyClass") - let ref3 = ResolvedTopicReference(id: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) + let ref3 = ResolvedTopicReference(bundleID: "bundle", path: "/MyClass/myFunction", sourceLanguage: .swift) XCTAssertEqual(ref3.absoluteString, "doc://bundle/MyClass/myFunction") } func testReferenceUpdatedAbsoluteString() { - var ref1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) + var ref1 = ResolvedTopicReference(bundleID: "bundle", path: "/", sourceLanguage: .swift) XCTAssertEqual(ref1.absoluteString, "doc://bundle/") ref1 = ref1.appendingPath("MyClass") XCTAssertEqual(ref1.absoluteString, "doc://bundle/MyClass") @@ -144,7 +144,7 @@ class IdentifierTests: XCTestCase { } func testResolvedTopicReferenceDoesNotCopyStorageIfNotModified() { - let reference1 = ResolvedTopicReference(id: "bundle", path: "/", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(bundleID: "bundle", path: "/", sourceLanguage: .swift) let reference2 = reference1 XCTAssertEqual( @@ -155,7 +155,7 @@ class IdentifierTests: XCTestCase { func testWithSourceLanguages() { let swiftReference = ResolvedTopicReference( - id: "bundle", + bundleID: "bundle", path: "/", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift index 28369bebf..85112fa85 100644 --- a/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift +++ b/Tests/SwiftDocCTests/Model/LineHighlighterTests.swift @@ -51,7 +51,7 @@ class LineHighlighterTests: XCTestCase { let catalog = Self.makeCatalog(tutorial: tutorialFile, codeFiles: codeFiles) let (bundle, context) = try loadBundle(catalog: catalog) - let tutorialReference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) + let tutorialReference = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Line-Highlighter-Tests/Tutorial", fragment: nil, sourceLanguage: .swift) let tutorial = try context.entity(with: tutorialReference).semantic as! Tutorial let section = tutorial.sections.first! return LineHighlighter(context: context, tutorialSection: section, tutorialReference: tutorialReference).highlights diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index a18356a3a..69cb2b70e 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -26,7 +26,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: `YES` if doing something was successful, or `NO` if an error occurred. // - (void)doSomethingWith:(NSInteger)someValue error:(NSError **)error; do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -47,7 +47,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Returns: Some string. If an error occurs, this method returns `nil` and assigns an appropriate error object to the `error` parameter. // - (nullable NSString *)returnSomethingAndReturnError:(NSError **)error; do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ErrorParameters/MyClassInObjectiveC/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -68,7 +68,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func doSomething(with someValue: Int) throws { } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/doSomething(with:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -93,7 +93,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { // /// - Throws: Some error if something does wrong // @objc public func returnSomething() throws -> String { "" } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ErrorParameters/MyClassInSwift/returnSomething()", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -435,7 +435,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -492,7 +492,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -534,7 +534,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/functionName(...)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) diff --git a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift index f49ab4c9d..44ef3dcbf 100644 --- a/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift +++ b/Tests/SwiftDocCTests/Model/PropertyListPossibleValuesSectionTests.swift @@ -83,7 +83,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testAbsenceOfPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/DictionaryData/Artist", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) // Check that the `Possible Values` section is not rendered if the symbol don't define any possible value. @@ -92,7 +92,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { func testUndocumentedPossibleValues() throws { let (_, bundle, context) = try testBundleAndContext(copying: "DictionaryData") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let possibleValuesSection = try XCTUnwrap(try converter.convert(node).primaryContentSections.first(where: { $0.kind == .possibleValues}) as? PossibleValuesRenderSection) let possibleValues: [PossibleValuesRenderSection.NamedValue] = possibleValuesSection.values @@ -116,7 +116,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) @@ -136,7 +136,7 @@ class PropertyListPossibleValuesSectionTests: XCTestCase { """.write(to: url.appendingPathComponent("Month.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/DictionaryData/Month", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol let possibleValues = try XCTUnwrap(symbol.possibleValuesSectionVariants.firstValue?.possibleValues) diff --git a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift index 41d3ef796..bb3e25fc2 100644 --- a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift @@ -68,7 +68,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTables() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -109,7 +109,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableSpans() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | @@ -162,7 +162,7 @@ class RenderContentMetadataTests: XCTestCase { func testRenderingTableColumnAlignments() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | one | two | three | four | @@ -204,7 +204,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that a table with `nil` alignments and a table with all-unset alignments still compare as equal. func testRenderedTableEquality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ | Column 1 | Column 2 | @@ -230,7 +230,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that two tables with otherwise-identical contents but different column alignments compare as unequal. func testRenderedTableInequality() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let decodedTableWithUnsetColumns: RenderBlockContent.Table do { @@ -277,7 +277,7 @@ class RenderContentMetadataTests: XCTestCase { func testStrikethrough() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ~~Striken~~ text. @@ -300,7 +300,7 @@ class RenderContentMetadataTests: XCTestCase { func testHeadingAnchorShouldBeEncoded() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ ## テスト diff --git a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift index 464a9925b..458a8ac7b 100644 --- a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift @@ -14,7 +14,7 @@ import XCTest class RenderHierarchyTranslatorTests: XCTestCase { func test() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let technologyReference = ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) + let technologyReference = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) var translator = RenderHierarchyTranslator(context: context, bundle: bundle) let renderHierarchy = translator.visitTutorialTableOfContentsNode(technologyReference)?.hierarchy @@ -100,7 +100,7 @@ class RenderHierarchyTranslatorTests: XCTestCase { } // Get a translated render node - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) let renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift index 56b584d84..34a158740 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift @@ -304,7 +304,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { modification: @escaping (URL) throws -> () ) throws -> JSONPatchDifferences { let (bundleOriginal, contextOriginal) = try testBundleAndContext(named: bundleName) - let nodeOriginal = try contextOriginal.entity(with: ResolvedTopicReference(id: bundleID, + let nodeOriginal = try contextOriginal.entity(with: ResolvedTopicReference(bundleID: bundleID, path: topicReferencePath, sourceLanguage: .swift)) var renderContext = RenderContext(documentationContext: contextOriginal, bundle: bundleOriginal) @@ -316,7 +316,7 @@ class RenderNodeDiffingBundleTests: XCTestCase { let (_, bundleModified, contextModified) = try testBundleAndContext(copying: bundleName) { url in try modification(url) } - let nodeModified = try contextModified.entity(with: ResolvedTopicReference(id: bundleID, + let nodeModified = try contextModified.entity(with: ResolvedTopicReference(bundleID: bundleID, path: topicReferencePath, sourceLanguage: .swift)) renderContext = RenderContext(documentationContext: contextModified, bundle: bundleModified) diff --git a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift index e32a51c45..523a02f18 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift @@ -14,7 +14,7 @@ import Markdown class RenderNodeSerializationTests: XCTestCase { func testRoundTrip() throws { - let inputIdentifier = ResolvedTopicReference(id: "com.example.docc", path: "/example", sourceLanguage: .swift) + let inputIdentifier = ResolvedTopicReference(bundleID: "com.example.docc", path: "/example", sourceLanguage: .swift) var inputNode = RenderNode(identifier: inputIdentifier, kind: .tutorial) let introSection = IntroRenderSection(title: "Basic Augmented Reality App") @@ -93,7 +93,7 @@ class RenderNodeSerializationTests: XCTestCase { func testBundleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -116,7 +116,7 @@ class RenderNodeSerializationTests: XCTestCase { func testTutorialArticleRoundTrip() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") @@ -141,7 +141,7 @@ class RenderNodeSerializationTests: XCTestCase { typealias JSONDictionary = [String: Any] let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -193,7 +193,7 @@ class RenderNodeSerializationTests: XCTestCase { func testDiffAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, article not found as first child.") diff --git a/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift b/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift index 0d30c21bb..370634138 100644 --- a/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift +++ b/Tests/SwiftDocCTests/Model/ResourceReferenceTests.swift @@ -13,7 +13,7 @@ import XCTest class ResourceReferenceTests: XCTestCase { func testPathWithSectionFragment() throws { - let ref = ResolvedTopicReference(id: "org.swift.docc.example", path: "/Test-Bundle/Tutorial1", sourceLanguage: .swift) + let ref = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/Test-Bundle/Tutorial1", sourceLanguage: .swift) XCTAssertEqual(ref.absoluteString, "doc://org.swift.docc.example/Test-Bundle/Tutorial1") let refAdvanced = ref.withFragment("fragment") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift index 0fd0211bd..ba6c3c0b9 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift @@ -444,7 +444,7 @@ class SemaToRenderNodeMixedLanguageTests: XCTestCase { """.write(to: url.appendingPathComponent("bar.md"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MixedLanguageFramework/Bar", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) XCTAssert(context.problems.isEmpty, "Encountered unexpected problems: \(context.problems)") diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift index 69ff95083..5893ffe9a 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift @@ -17,7 +17,7 @@ import SwiftDocCTestUtilities class SemaToRenderNodeTests: XCTestCase { func testCompileTutorial() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -46,7 +46,7 @@ class SemaToRenderNodeTests: XCTestCase { XCTAssertFalse(jsonString.contains("This is a comment")) } - XCTAssertEqual(renderNode.identifier, ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + XCTAssertEqual(renderNode.identifier, ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) XCTAssertEqual(renderNode.sections.count, 4) guard let intro = renderNode.sections.first as? IntroRenderSection else { @@ -404,7 +404,7 @@ class SemaToRenderNodeTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "TestBundle") func assertTutorialWithPath(_ tutorialPath: String, hasBackground backgroundIdentifier: String) throws { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: tutorialPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: tutorialPath, sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -432,7 +432,7 @@ class SemaToRenderNodeTests: XCTestCase { func testCompileTutorialArticle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) let article = node.semantic as! TutorialArticle @@ -570,7 +570,7 @@ class SemaToRenderNodeTests: XCTestCase { } private func assertCompileOverviewWithNoVolumes(bundle: DocumentationBundle, context: DocumentationContext, expectedProblemsCount: Int = 0) throws { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -807,7 +807,7 @@ class SemaToRenderNodeTests: XCTestCase { try text.write(to: overviewURL, atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -941,7 +941,7 @@ class SemaToRenderNodeTests: XCTestCase { try JSONEncoder().encode(graph).write(to: graphURL) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Verify that `MyProtocol` the symbol is loaded in the topic graph, but the `MyProtocol` sidecar article was removed. let matches = context.knownPages.filter({ reference -> Bool in @@ -1175,7 +1175,7 @@ class SemaToRenderNodeTests: XCTestCase { func testCompileSymbolWithExternalReferences() throws { class TestSymbolResolver: GlobalExternalSymbolResolver { func symbolReferenceAndEntity(withPreciseIdentifier preciseIdentifier: String) -> (ResolvedTopicReference, LinkResolver.ExternalEntity)? { - let reference = ResolvedTopicReference(id: "com.test.external.symbols", path: "/\(preciseIdentifier)", sourceLanguage: .objectiveC) + let reference = ResolvedTopicReference(bundleID: "com.test.external.symbols", path: "/\(preciseIdentifier)", sourceLanguage: .objectiveC) let entity = LinkResolver.ExternalEntity( topicRenderReference: TopicRenderReference( @@ -1198,7 +1198,7 @@ class SemaToRenderNodeTests: XCTestCase { func resolve(_ reference: TopicReference) -> TopicReferenceResolutionResult { .success( ResolvedTopicReference( - id: "com.test.external", + bundleID: "com.test.external", path: reference.url!.path, sourceLanguage: .swift ) @@ -1326,7 +1326,7 @@ class SemaToRenderNodeTests: XCTestCase { // Check for constraints in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1346,7 +1346,7 @@ class SemaToRenderNodeTests: XCTestCase { }.joined(), "Label is Text, Observer inherits NSObject, and S conforms to StringProtocol.") // Check for constraints in render references - let parent = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let parent = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let parentSymbol = parent.semantic as! Symbol var parentTranslator = RenderNodeTranslator(context: context, bundle: bundle, identifier: parent.reference) @@ -1379,7 +1379,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnConformingType() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1401,7 +1401,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderConditionalConstraintsOnProtocol() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -1423,7 +1423,7 @@ class SemaToRenderNodeTests: XCTestCase { func testRenderReferenceResolving() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1488,7 +1488,7 @@ class SemaToRenderNodeTests: XCTestCase { func testAvailabilityMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1549,7 +1549,7 @@ class SemaToRenderNodeTests: XCTestCase { } }) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1576,7 +1576,7 @@ class SemaToRenderNodeTests: XCTestCase { func testMediaReferencesWithSpaces() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -1637,7 +1637,7 @@ Document @1:1-11:19 markup.debugDescription(options: .printSourceLocations)) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1679,7 +1679,7 @@ Document markup.debugDescription()) let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ .paragraph(.init(inlineContent: [ @@ -1702,7 +1702,7 @@ Document """ let document = Document(parsing: markupSource, options: []) - let node = DocumentationNode(reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) + let node = DocumentationNode(reference: ResolvedTopicReference(bundleID: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) let (bundle, context) = try testBundleAndContext(named: "TestBundle") var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1711,7 +1711,7 @@ Document func testCompileSymbolMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = node.semantic as! Symbol @@ -1819,7 +1819,7 @@ Document try content.write(to: targetURL.appendingPathComponent("article2.md"), atomically: true, encoding: .utf8) let (_, bundle, context) = try loadBundle(from: targetURL) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article2", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return translator.visit(article) as! RenderNode @@ -1907,7 +1907,7 @@ Document let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) return (bundle, context, reference) } @@ -2061,14 +2061,14 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: nil, deprecatedVersion: .init(major: 13, minor: 0, patch: 0), obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), ]) } - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2084,7 +2084,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2092,7 +2092,7 @@ Document ]) } - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2108,7 +2108,7 @@ Document // Make the referenced symbol deprecated do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) let node = try context.entity(with: reference) (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [ SymbolGraph.Symbol.Availability.AvailabilityItem(domain: .init(rawValue: "iOS"), introducedVersion: .init(major: 13, minor: 0, patch: 0), deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: true, isUnconditionallyUnavailable: false, willEventuallyBeDeprecated: false), @@ -2116,7 +2116,7 @@ Document ]) } - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = node.semantic as! Symbol @@ -2131,7 +2131,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2151,7 +2151,7 @@ Document func testRenderMetadataExtendedModule() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2165,7 +2165,7 @@ Document // Verify that the render reference to a required symbol includes the 'required' key and the number of default implementations provided. do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2178,7 +2178,7 @@ Document // Verify that a required symbol includes a required metadata and default implementations do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2198,7 +2198,7 @@ Document // Verify that a required symbol does not include default implementations in Topics groups do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideProtocol/func()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(symbol) as! RenderNode @@ -2213,7 +2213,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2242,7 +2242,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2261,7 +2261,7 @@ Document func testDocumentationRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2281,7 +2281,7 @@ Document func testTutorialsRenderReferenceRoles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) let symbol = node.semantic as! TutorialTableOfContents var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2301,7 +2301,7 @@ Document // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol // Subheading with trailing "\n" @@ -2323,7 +2323,7 @@ Document func testRenderManualSeeAlsoInArticles() throws { // Check for fragments in metadata in render node let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) let article = node.semantic as! Article var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2346,7 +2346,7 @@ Document func testSafeSectionAnchorNames() throws { // Check that heading's anchor was safe-ified let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2367,7 +2367,7 @@ Document func testDuplicateNavigatorTitleIsRemoved() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2383,7 +2383,7 @@ Document func testNonDuplicateNavigatorTitleIsRendered() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = node.semantic as! Symbol @@ -2440,7 +2440,7 @@ Document """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let tutorialTableOfContentsDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial table-of-contents not found as first child.") @@ -2461,7 +2461,7 @@ Document _ = translator.visit(tutorialTableOfContents) do { - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2532,7 +2532,7 @@ Document """.write(to: url.appendingPathComponent("TestTutorial.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") @@ -2576,8 +2576,8 @@ Document XCTAssertEqual(Array(asides.content.dropFirst()), self.asidesStressTest) } - let dashReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) - let quoteReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) + let dashReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Asides/dashAsides()", sourceLanguage: .swift) + let quoteReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Asides/quoteAsides()", sourceLanguage: .swift) try testReference(dashReference) try testReference(quoteReference) @@ -2587,7 +2587,7 @@ Document func testOriginMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) let origin = try XCTUnwrap(symbol.origin) @@ -2609,7 +2609,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2636,7 +2636,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2662,7 +2662,7 @@ Document return p.diagnostic.summary == "Resource 'my-inherited-image.png' couldn't be found" })) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2691,7 +2691,7 @@ Document """.write(to: url.appendingPathComponent("inherited.md"), atomically: true, encoding: .utf8) }) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2836,7 +2836,7 @@ Document .write(to: url.appendingPathComponent("sidekit.symbols.json")) }) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2866,7 +2866,7 @@ Document problem.diagnostic.summary.contains("my-inherited-image.png") })) - let myFuncReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) + let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2901,7 +2901,7 @@ Document func testNonDocumentedSymbolNilAbstract() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -3016,7 +3016,7 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -3057,9 +3057,9 @@ Document """.write(to: url.appendingPathComponent("documentation").appendingPathComponent("myprotocol.md"), atomically: true, encoding: .utf8) }) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) - let protocolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) - let functionReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let protocolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) + let functionReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift) // Verify the MyKit module @@ -3141,13 +3141,13 @@ Document // Verify that the inherited symbol got a path that accounts for the collision between // the struct `B` and the property `b`. - let inheritedSymbolReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) + let inheritedSymbolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/!=(_:_:)", sourceLanguage: .swift) XCTAssertNoThrow(try context.entity(with: inheritedSymbolReference)) // Verify that the inherited symbol is automatically curated with its correct // reference path under the inherited symbols API collection - let equatableImplementationsReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) + let equatableImplementationsReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Minimal_docs/A/B-swift.struct/Equatable-Implementations", sourceLanguage: .swift) let equatableImplementationsNode = try context.entity(with: equatableImplementationsReference) let equatableImplementationsArticle = try XCTUnwrap(equatableImplementationsNode.semantic as? Article) let group = try XCTUnwrap(equatableImplementationsArticle.automaticTaskGroups.first) @@ -3179,7 +3179,7 @@ Document } """.write(to: url.appendingPathComponent("TestOverview.tutorial"), atomically: true, encoding: .utf8) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) guard let technologyDirective = node.markup as? BlockDirective else { XCTFail("Unexpected document structure, tutorial not found as first child.") return @@ -3224,7 +3224,7 @@ Document ) let moduleReference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3267,7 +3267,7 @@ Document ) let articleReference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -3436,7 +3436,7 @@ Document } do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/GeometricalShapes/Circle", sourceLanguage: .swift) let node = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -3487,7 +3487,7 @@ Document let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Model/TaskGroupTests.swift b/Tests/SwiftDocCTests/Model/TaskGroupTests.swift index 688cca95c..c8eb7bb34 100644 --- a/Tests/SwiftDocCTests/Model/TaskGroupTests.swift +++ b/Tests/SwiftDocCTests/Model/TaskGroupTests.swift @@ -69,7 +69,7 @@ class SectionExtractionTests: XCTestCase { } private func testNode(with document: Document) -> DocumentationNode { - return DocumentationNode(reference: ResolvedTopicReference(id: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) + return DocumentationNode(reference: ResolvedTopicReference(bundleID: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) } func testSection() { diff --git a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift index 48a33fd16..4da3267fd 100644 --- a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift @@ -30,7 +30,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -61,7 +61,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -104,7 +104,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -121,7 +121,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that articles get same automatic See Also sections as symbols do { - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -171,7 +171,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -184,7 +184,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that article without options directive still gets automatic See Also sections do { - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -235,7 +235,7 @@ class AutomaticSeeAlsoTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -248,7 +248,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Verify that article without options directive still gets automatic See Also sections do { - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/sidearticle", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Article) as! RenderNode @@ -286,7 +286,7 @@ class AutomaticSeeAlsoTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: bundleURL) // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "MyKit", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "MyKit", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift index d4f143b73..dce36ead8 100644 --- a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift @@ -24,7 +24,7 @@ class AvailabilityRenderOrderTests: XCTestCase { try? FileManager.default.removeItem(at: bundleURL) } - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Availability/MyStruct", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift index 66a89b05f..705f5d25b 100644 --- a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift @@ -40,7 +40,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -70,7 +70,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -99,7 +99,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -129,7 +129,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -159,7 +159,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -190,7 +190,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -220,7 +220,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode @@ -258,7 +258,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } // Compile docs and verify contents - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visitSymbol(symbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift index 4de3f9993..684edf0a7 100644 --- a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift @@ -135,7 +135,7 @@ class DeclarationsRenderSectionTests: XCTestCase { func testAlternateDeclarations() throws { let (bundle, context) = try testBundleAndContext(named: "AlternateDeclarations") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AlternateDeclarations/MyClass/present(completion:)", sourceLanguage: .swift ) @@ -186,7 +186,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload1(param: Set) {} // func overload1(param: [Int: Int]) {} let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/FancyOverloads/overload1(param:)", sourceLanguage: .swift ) @@ -237,7 +237,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload2(p1: (Int) -> Int?, p2: Int) {} // func overload2(p1: ((Int) -> Int)?, p2: Int) {} // <- overload group let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/FancyOverloads/overload2(p1:p2:)", sourceLanguage: .swift ) @@ -292,7 +292,7 @@ class DeclarationsRenderSectionTests: XCTestCase { // func overload3(_ p: [T: T]) {} // func overload3(_ p: [K: V]) {} let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/FancyOverloads/overload3(_:)", sourceLanguage: .swift ) @@ -342,7 +342,7 @@ class DeclarationsRenderSectionTests: XCTestCase { for hash in ["7eht8", "8p1lo", "858ja"] { let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/FancyOverloads/overload3(_:)-\(hash)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift index c4e79ad5e..65d81a964 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift @@ -71,7 +71,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is used for modules do { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -81,7 +81,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is used for symbols with no explicit availability do { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-3743d", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/init()-3743d", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -91,7 +91,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the default availability is NOT used for symbols with explicit availability do { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -185,7 +185,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test if the module availability is not "beta" for the "macOS" platform (since 10.15.1 != 10.16) do { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -205,7 +205,7 @@ class DefaultAvailabilityTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) do { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) // Add some available and unavailable platforms to the symbol @@ -336,7 +336,7 @@ class DefaultAvailabilityTests: XCTestCase { let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) @@ -665,7 +665,7 @@ class DefaultAvailabilityTests: XCTestCase { XCTAssertNotNil(availability.first(where: { $0.domain?.rawValue == "iOS" })) XCTAssertEqual(availability.first(where: { $0.domain?.rawValue == "iOS" })?.introducedVersion, nil) // Verify we remove the version from the module availability information. - var identifier = ResolvedTopicReference(id: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) + var identifier = ResolvedTopicReference(bundleID: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) var node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) var renderNode = translator.visit(node.semantic) as! RenderNode @@ -708,7 +708,7 @@ class DefaultAvailabilityTests: XCTestCase { XCTAssertEqual(availability.first(where: { $0.domain?.rawValue == "watchOS" })?.introducedVersion, nil) // Verify the module availability shows as expected. - identifier = ResolvedTopicReference(id: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) + identifier = ResolvedTopicReference(bundleID: "test", path: "/documentation/MyModule", fragment: nil, sourceLanguage: .swift) node = try context.entity(with: identifier) translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: identifier) renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift index e0c14c0d8..88148d8fa 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift @@ -25,7 +25,7 @@ class DefaultCodeBlockSyntaxTests: XCTestCase { override func setUpWithError() throws { func renderSection(for bundle: DocumentationBundle, in context: DocumentationContext) throws -> ContentRenderSection { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) diff --git a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift index c78d6e4c2..6e2121248 100644 --- a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift @@ -32,7 +32,7 @@ class DeprecationSummaryTests: XCTestCase { /// and it's preferred over the original deprecation note in the code docs. func testAuthoredDeprecatedSummary() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -63,7 +63,7 @@ class DeprecationSummaryTests: XCTestCase { }) // Verify the deprecation is still rendered. - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift)) // Compile docs and verify contents let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -83,7 +83,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass", sourceLanguage: .swift ) @@ -115,7 +115,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass/doUncoolThings(with:)", sourceLanguage: .swift ) @@ -137,7 +137,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass/init()", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass/coolFunc()", sourceLanguage: .swift ) @@ -195,7 +195,7 @@ class DeprecationSummaryTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "BundleWithLonelyDeprecationDirective") let node = try context.entity( with: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/CoolFramework/CoolClass/init(config:cache:)", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift b/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift index 7d6a829ea..db9f15b22 100644 --- a/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift @@ -146,7 +146,7 @@ private extension DocumentationContentRendererTests { var nodeWithSubheadingAndNavigatorVariants: DocumentationNode { var node = DocumentationNode( reference: ResolvedTopicReference( - id: "org.swift.example", + bundleID: "org.swift.example", path: "/documentation/class", fragment: nil, sourceLanguage: .swift @@ -198,7 +198,7 @@ private extension DocumentationContentRendererTests { ]), roleHeadingVariants: .init(swiftVariant: ""), platformNameVariants: .init(swiftVariant: nil), - moduleReference: ResolvedTopicReference(id: "", path: "", sourceLanguage: .swift), // This information isn't used anywhere. + moduleReference: ResolvedTopicReference(bundleID: "", path: "", sourceLanguage: .swift), // This information isn't used anywhere. externalIDVariants: .init(swiftVariant: nil), accessLevelVariants: .init(swiftVariant: nil), availabilityVariants: .init(swiftVariant: Availability(availability: [])), diff --git a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift index 41965079b..ffe4a206c 100644 --- a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift @@ -15,7 +15,7 @@ import Markdown public class ExternalLinkTitleTests: XCTestCase { private func getTranslatorAndBlockContentForMarkup(_ markupSource: String) throws -> (translator: RenderNodeTranslator, content: [RenderBlockContent]) { let document = Document(parsing: markupSource, options: [.parseBlockDirectives, .parseSymbolLinks]) - let testReference = ResolvedTopicReference(id: "org.swift.docc", path: "/test", sourceLanguage: .swift) + let testReference = ResolvedTopicReference(bundleID: "org.swift.docc", path: "/test", sourceLanguage: .swift) let node = DocumentationNode(reference: testReference, kind: .article, sourceLanguage: .swift, diff --git a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift index f61ca7414..893d60c50 100644 --- a/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/MentionsRenderSectionTests.swift @@ -19,12 +19,12 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift ) let mentioningArticle = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift ) @@ -42,7 +42,7 @@ class MentionsRenderSectionTests: XCTestCase { enableFeatureFlag(\.isExperimentalMentionedInEnabled) let (bundle, context) = try createMentionedInTestBundle() let identifier = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/MyClass/myFunction()", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift index d558b20ae..16aa6ce89 100644 --- a/Tests/SwiftDocCTests/Rendering/PageKindTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PageKindTests.swift @@ -18,7 +18,7 @@ class PageKindTests: XCTestCase { private func generateRenderNodeFromBundle(bundleName: String, resolvedTopicPath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: bundleName) let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: resolvedTopicPath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift index 1a5bc1491..c36bc68f3 100644 --- a/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PlatformAvailabilityTests.swift @@ -36,7 +36,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -55,7 +55,7 @@ class PlatformAvailabilityTests: XCTestCase { func testPlatformAvailabilityFromExtension() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -73,7 +73,7 @@ class PlatformAvailabilityTests: XCTestCase { func testMultiplePlatformAvailabilityFromArticle() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -101,7 +101,7 @@ class PlatformAvailabilityTests: XCTestCase { func testArbitraryPlatformAvailability() throws { let (bundle, context) = try testBundleAndContext(named: "AvailabilityBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AvailabilityBundle/ArbitraryPlatforms", sourceLanguage: .swift ) @@ -127,7 +127,7 @@ class PlatformAvailabilityTests: XCTestCase { let (bundle, context) = try testBundleAndContext(named: "AvailabilityOverrideBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -166,7 +166,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AvailableArticle", sourceLanguage: .swift ) @@ -189,7 +189,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/AvailabilityBundle/ComplexAvailable", sourceLanguage: .swift ) @@ -221,7 +221,7 @@ class PlatformAvailabilityTests: XCTestCase { ] let (bundle, context) = try testBundleWithConfiguredPlatforms(named: "AvailabilityBundle", platformMetadata: platformMetadata) let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift index c5772c22c..8d0e742de 100644 --- a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift @@ -332,7 +332,7 @@ class RESTSymbolsTests: XCTestCase { ] + extraFiles ) let (_, bundle, context) = try loadBundle(from: (try createTempFolder(content: [exampleDocumentation]))) - let moduleReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let moduleSymbol = try XCTUnwrap((try context.entity(with: moduleReference)).semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: moduleReference) let renderNode = translator.visit(moduleSymbol) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift index 7caec65c1..3fe7834d7 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderBlockContent_ThematicBreakTests.swift @@ -40,7 +40,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -67,7 +67,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -97,7 +97,7 @@ class RenderBlockContent_ThematicBreakTests: XCTestCase { let (bundle, context) = try testBundleAndContext() - var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) + var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestThematicBreak", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ diff --git a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift index 6c397f2c9..1fadc6e30 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift @@ -16,7 +16,7 @@ import XCTest class RenderContentCompilerTests: XCTestCase { func testLinkOverrideTitle() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ [Example](http://example.com) @@ -134,7 +134,7 @@ class RenderContentCompilerTests: XCTestCase { func testLineBreak() throws { let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" Backslash before new line\ @@ -199,7 +199,7 @@ class RenderContentCompilerTests: XCTestCase { func testThematicBreak() throws { let (bundle, context) = try testBundleAndContext() - var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" diff --git a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift index 7e5cc6276..22787e004 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift @@ -100,7 +100,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction1()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -127,7 +127,7 @@ class RenderMetadataTests: XCTestCase { } // Verify the symbol from bystanders graph is present in the documentation context. - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/BaseKit/OtherStruct/someFunc()", sourceLanguage: .swift) let entity = try XCTUnwrap(try? context.entity(with: reference)) let symbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -149,7 +149,7 @@ class RenderMetadataTests: XCTestCase { } // Get a translated render node - let node = try context.entity(with: ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency/AmbiguousType", sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/BundleWithRelativePathAmbiguity/Dependency/AmbiguousType", sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode XCTAssertEqual(renderNode.metadata.modules?.first?.name, "BundleWithRelativePathAmbiguity") diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift index f85f4ebdc..bb3998d22 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift @@ -35,7 +35,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModules() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: resolvedTopicReference.bundleID, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -51,7 +51,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModulesWithBystanderModule() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: resolvedTopicReference.bundleID, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -79,7 +79,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testMultipleModulesWithDifferentBystanderModule() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: resolvedTopicReference.bundleID, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Extended Module Title") context.preResolveModuleNames() }, @@ -125,7 +125,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { func testPlatformsVariantsDefaultAvailability() throws { try assertMultiVariantSymbol( configureContext: { context, resolvedTopicReference in - let moduleReference = ResolvedTopicReference(id: resolvedTopicReference.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = ResolvedTopicReference(bundleID: resolvedTopicReference.bundleID, path: "/documentation/MyKit", sourceLanguage: .swift) context.documentationCache[moduleReference]?.name = .conceptual(title: "Custom Module Title") context.preResolveModuleNames() }, @@ -665,7 +665,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { // Set up an Objective-C title for MyProtocol. let myFunctionNode = try context.entity( with: ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", fragment: nil, sourceLanguage: .swift @@ -716,7 +716,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { // Set up an Objective-C title for MyProtocol. let myFunctionNode = try context.entity( with: ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyProtocol", fragment: nil, sourceLanguage: .swift @@ -755,7 +755,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { configureContext: { context, reference in try makeSymbolAvailableInSwiftAndObjectiveC( symbolPath: "/documentation/MyKit/MyProtocol", - id: reference.id, + id: reference.bundleID, context: context ) }, @@ -887,7 +887,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { Implementation( reference: .successfullyResolved( ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift @@ -954,7 +954,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { configureContext: { context, reference in try makeSymbolAvailableInSwiftAndObjectiveC( symbolPath: "/documentation/MyKit/MyProtocol", - id: reference.id, + id: reference.bundleID, context: context ) }, @@ -1146,7 +1146,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let myFunctionNode = try context.entity( with: ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift @@ -1188,7 +1188,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: bundleName) let identifier = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift ) @@ -1225,7 +1225,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") let identifier = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift ) @@ -1298,7 +1298,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { destinations: [ TopicReference.successfullyResolved( ResolvedTopicReference( - id: "org.swift.docc.example", + bundleID: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift @@ -1327,7 +1327,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { id: DocumentationBundle.Identifier, context: DocumentationContext ) throws { - let reference = ResolvedTopicReference(id: id, path: symbolPath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: id, path: symbolPath, sourceLanguage: .swift) context.documentationCache[reference]?.availableSourceLanguages = [.swift, .objectiveC] } diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift index f9e07371b..167405ca0 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift @@ -19,7 +19,7 @@ class RenderNodeTranslatorTests: XCTestCase { private func findDiscussion(forSymbolPath: String, configureBundle: ((URL) throws -> Void)? = nil) throws -> ContentRenderSection? { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", configureBundle: configureBundle) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: forSymbolPath, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: forSymbolPath, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic as! Symbol) as! RenderNode @@ -291,7 +291,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) let node = try context.entity(with: reference) let article = try XCTUnwrap(node.semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -341,7 +341,7 @@ class RenderNodeTranslatorTests: XCTestCase { let article = try XCTUnwrap( Article(from: document.root, source: nil, for: bundle, in: context, problems: &problems) ) - let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/taskgroups", fragment: nil, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/taskgroups", fragment: nil, sourceLanguage: .swift) context.documentationCache[reference] = try DocumentationNode(reference: reference, article: article) let topicGraphNode = TopicGraph.Node(reference: reference, kind: .article, source: .file(url: URL(fileURLWithPath: "/path/to/article.md")), title: "My Article") context.topicGraph.addNode(topicGraphNode) @@ -375,7 +375,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -406,7 +406,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -440,7 +440,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -451,7 +451,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -462,7 +462,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -502,7 +502,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -525,7 +525,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -553,7 +553,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Articles", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -564,7 +564,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Default Implementations", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -575,7 +575,7 @@ class RenderNodeTranslatorTests: XCTestCase { title: "Another Task Group", references: [ ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift ), @@ -605,7 +605,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify "Default Implementations" group on the implementing type do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -624,7 +624,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verify automatically generated api collection do { - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/Protocol-Implementations", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -653,7 +653,7 @@ class RenderNodeTranslatorTests: XCTestCase { try? FileManager.default.copyItem(at: fancyProtocolSGFURL, to: url.appendingPathComponent("FancyProtocol.symbols.json")) } - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/FancyProtocol/SomeClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -856,7 +856,7 @@ class RenderNodeTranslatorTests: XCTestCase { func loadRenderNode(at path: String, in bundleURL: URL) throws -> RenderNode { let (_, bundle, context) = try loadBundle(from: bundleURL) - let reference = ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try context.entity(with: reference) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -865,7 +865,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testAutomaticTaskGroupTopicsAreSorted() throws { let (bundle, context) = try testBundleAndContext(named: "DefaultImplementations") - let structReference = ResolvedTopicReference(id: bundle.id, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) + let structReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/DefaultImplementations/Foo", sourceLanguage: .swift) let structNode = try context.entity(with: structReference) let symbol = try XCTUnwrap(structNode.semantic as? Symbol) @@ -899,7 +899,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let node = try XCTUnwrap(try? context.entity(with: reference)) @@ -927,7 +927,7 @@ class RenderNodeTranslatorTests: XCTestCase { // First verify that `SideKit` page does not contain render reference to `SideKit/SideClass/Element`. let (bundle, context) = try testBundleAndContext(named: "TestBundle") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -947,7 +947,7 @@ class RenderNodeTranslatorTests: XCTestCase { """.write(to: url.appendingPathComponent("sideclass.md"), atomically: true, encoding: .utf8) }) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) @@ -961,7 +961,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -991,7 +991,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1015,7 +1015,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testNestedSnippetSliceToCodeListing() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Snippets/Snippets", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1046,7 +1046,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSnippetSliceTrimsIndentation() throws { let (bundle, context) = try testBundleAndContext(named: "Snippets") - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Snippets/SliceIndentation", sourceLanguage: .swift) let article = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) let renderNode = try XCTUnwrap(translator.visitArticle(article) as? RenderNode) @@ -1072,7 +1072,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRowAndColumn() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1101,7 +1101,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testSmall() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1129,7 +1129,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTabNavigator() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/BestBook/TabNavigatorArticle", sourceLanguage: .swift ) @@ -1166,7 +1166,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testRenderNodeMetadata() throws { let (bundle, context) = try testBundleAndContext(named: "BookLikeContent") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/BestBook/MyArticle", sourceLanguage: .swift ) @@ -1242,7 +1242,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testPageColorMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1258,7 +1258,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testTitleHeadingMetadataInSymbolExtension() throws { let (bundle, context) = try testBundleAndContext(named: "MixedManualAutomaticCuration") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/TestBed", sourceLanguage: .swift ) @@ -1340,7 +1340,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(id: bundle.id, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) @@ -1433,7 +1433,7 @@ class RenderNodeTranslatorTests: XCTestCase { func renderNodeArticleFromReferencePath( referencePath: String ) throws -> RenderNode { - let reference = ResolvedTopicReference(id: bundle.id, path: referencePath, sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: referencePath, sourceLanguage: .swift) let symbol = try XCTUnwrap(context.entity(with: reference).semantic as? Article) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: reference) return try XCTUnwrap(translator.visitArticle(symbol) as? RenderNode) diff --git a/Tests/SwiftDocCTests/Rendering/RoleTests.swift b/Tests/SwiftDocCTests/Rendering/RoleTests.swift index e3cd507ce..af578d495 100644 --- a/Tests/SwiftDocCTests/Rendering/RoleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RoleTests.swift @@ -29,7 +29,7 @@ class RoleTests: XCTestCase { // Compile docs and verify contents for (path, expectedRole) in expectedRoles { - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: path, fragment: nil, sourceLanguage: .swift) do { let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -45,7 +45,7 @@ class RoleTests: XCTestCase { func testDocumentationRenderReferenceRoles() throws { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode @@ -58,7 +58,7 @@ class RoleTests: XCTestCase { func testTutorialsRenderReferenceRoles() throws { let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") - let identifier = ResolvedTopicReference(id: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", fragment: nil, sourceLanguage: .swift) + let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let renderNode = translator.visit(node.semantic) as! RenderNode diff --git a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift index b73a6e1d4..d139af629 100644 --- a/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift +++ b/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift @@ -128,7 +128,7 @@ class SampleDownloadTests: XCTestCase { private func renderNodeFromSampleBundle(at referencePath: String) throws -> RenderNode { let (bundle, context) = try testBundleAndContext(named: "SampleBundle") let reference = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: referencePath, sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index 2872bb265..527a38e98 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -87,7 +87,7 @@ class TermListTests: XCTestCase { let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: ["com.external.testbundle": resolver]) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) let converter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -161,7 +161,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - term First term : A paragraph that @@ -204,7 +204,7 @@ class TermListTests: XCTestCase { } let (bundle, context) = try testBundleAndContext(named: "TestBundle") - var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(id: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) + var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ - Not a term list, and diff --git a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift index a77676ba8..b6d64be2e 100644 --- a/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ArticleSymbolMentionsTests.swift @@ -18,11 +18,11 @@ class ArticleSymbolMentionsTests: XCTestCase { /// Test that the recording abstraction for ``ArticleSymbolMentions`` works as expected. func testArticlesMentioningSymbol() throws { let article = ResolvedTopicReference( - id: "org.swift.anything", + bundleID: "org.swift.anything", path: "/article", sourceLanguage: .swift ) - let symbol = ResolvedTopicReference(id: "org.swift.anything", path: "/Thing", sourceLanguage: .swift) + let symbol = ResolvedTopicReference(bundleID: "org.swift.anything", path: "/Thing", sourceLanguage: .swift) var mentions = ArticleSymbolMentions() XCTAssertTrue(mentions.articlesMentioning(symbol).isEmpty) @@ -47,11 +47,11 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertEqual(1, context.articleSymbolMentions.mentions.count) let mentioningArticle = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/ArticleMentioningSymbol", sourceLanguage: .swift) let mentionedSymbol = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) @@ -68,7 +68,7 @@ class ArticleSymbolMentionsTests: XCTestCase { XCTAssertTrue(context.articleSymbolMentions.mentions.isEmpty) let mentionedSymbol = ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/documentation/MentionedIn/MyClass", sourceLanguage: .swift) diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 075dfccbf..8abb9cd78 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -89,7 +89,7 @@ class DoxygenTests: XCTestCase { ]) let (_, bundle, context) = try loadBundle(from: tempURL) - let reference = ResolvedTopicReference(id: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) // Verify the expected content in the in-memory model let node = try context.entity(with: reference) diff --git a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift index d0209fe17..a81dbc646 100644 --- a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift @@ -395,7 +395,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeNode() throws { let title = "unreferenced-tutorial" - let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: URL(fileURLWithPath: "/path/to/\(title)")), title: title) let (_, context) = try testBundleAndContext(named: "TestBundle") @@ -414,7 +414,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeExternalNode() throws { let title = "unreferenced-tutorial" - let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .external, title: title) let (_, context) = try testBundleAndContext(named: "TestBundle") @@ -433,7 +433,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' func testAnalyzeFragmentNode() throws { let title = "unreferenced-tutorial" let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(id: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. TopicGraph.Node { let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(id: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. TopicGraph.Node { let url = URL(fileURLWithPath: "/path/to/\(title)") - let reference = ResolvedTopicReference(id: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TutorialArticleTests", path: "/\(title)", sourceLanguage: .swift) let range = SourceLocation(line: 1, column: 1, source: url).. RenderNode { let (bundle, context) = try testBundleAndContext(named: testBundleName) - let node = try context.entity(with: ResolvedTopicReference(id: bundle.id, path: path, sourceLanguage: .swift)) + let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift)) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) return try XCTUnwrap(translator.visit(node.semantic) as? RenderNode) } @@ -273,7 +273,7 @@ extension XCTestCase { context: context, bundle: bundle, identifier: ResolvedTopicReference( - id: bundle.id, + bundleID: bundle.id, path: "/test-path-123", sourceLanguage: .swift ) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift index b839c6012..b112eef5b 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift @@ -25,7 +25,7 @@ class ConvertActionIndexerTests: XCTestCase { // Add /documentation/MyKit to the index, verify the tree dump do { - let reference = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let reference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let renderNode = try converter.convert(context.entity(with: reference)) let tempIndexURL = try createTemporaryDirectory(named: "index") @@ -47,10 +47,10 @@ class ConvertActionIndexerTests: XCTestCase { // Add two nodes /documentation/MyKit and /documentation/Test-Bundle/Default-Code-Listing-Syntax to the index // and verify the tree. do { - let reference1 = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) + let reference1 = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift) let renderNode1 = try converter.convert(context.entity(with: reference1)) - let reference2 = ResolvedTopicReference(id: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", sourceLanguage: .swift) + let reference2 = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/Test-Bundle/Default-Code-Listing-Syntax", sourceLanguage: .swift) let renderNode2 = try converter.convert(context.entity(with: reference2)) let tempIndexURL = try createTemporaryDirectory(named: "index") diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index 9a96d31d2..43700d7fb 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -1754,7 +1754,7 @@ class ConvertActionTests: XCTestCase { struct TestReferenceResolver: ExternalDocumentationSource { func resolve(_ reference: TopicReference) -> TopicReferenceResolutionResult { - return .success(ResolvedTopicReference(id: "com.example.test", path: reference.url!.path, sourceLanguage: .swift)) + return .success(ResolvedTopicReference(bundleID: "com.example.test", path: reference.url!.path, sourceLanguage: .swift)) } func entity(with reference: ResolvedTopicReference) -> LinkResolver.ExternalEntity { diff --git a/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift b/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift index b7764cce9..4f31b23ad 100644 --- a/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/JSONEncodingRenderNodeWriterTests.swift @@ -32,7 +32,7 @@ class JSONEncodingRenderNodeWriterTests: XCTestCase { transformForStaticHostingIndexHTML: indexHTML ) - let renderNode = RenderNode(identifier: .init(id: "com.test", path: "/documentation/test", sourceLanguage: .swift), kind: .article) + let renderNode = RenderNode(identifier: .init(bundleID: "com.test", path: "/documentation/test", sourceLanguage: .swift), kind: .article) // We take precautions in case we deadlock to stop the execution with a failing code. // In case the original issue is present and we deadlock, we fatalError from a bg thread. diff --git a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift index 59cc676b2..296ef973e 100644 --- a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift @@ -47,7 +47,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { let resolver = try OutOfProcessReferenceResolver(processLocation: executableLocation, errorOutputHandler: { errorMessage in XCTFail("No error output is expected for this test executable. Got:\n\(errorMessage)") }) - XCTAssertEqual(resolver.id, "com.test.bundle") + XCTAssertEqual(resolver.bundleID, "com.test.bundle") #endif } @@ -88,7 +88,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { ) let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.id, "com.test.bundle") + XCTAssertEqual(resolver.bundleID, "com.test.bundle") // Resolve the reference let unresolved = TopicReference.unresolved( @@ -267,7 +267,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.id, "com.test.bundle") + XCTAssertEqual(resolver.bundleID, "com.test.bundle") // Resolve the symbol let (_, entity) = try XCTUnwrap(resolver.symbolReferenceAndEntity(withPreciseIdentifier: "abc123"), "Unexpectedly failed to resolve symbol") @@ -423,14 +423,14 @@ class OutOfProcessReferenceResolverTests: XCTestCase { XCTAssertEqual(errorMessage, "Some error output\n") didReadErrorOutputExpectation.fulfill() }) - XCTAssertEqual(resolver?.id, "com.test.bundle") + XCTAssertEqual(resolver?.bundleID, "com.test.bundle") wait(for: [didReadErrorOutputExpectation], timeout: 20.0) #endif } func assertForwardsResolverErrors(resolver: OutOfProcessReferenceResolver, file: StaticString = #file, line: UInt = #line) throws { - XCTAssertEqual(resolver.id, "com.test.bundle", file: file, line: line) + XCTAssertEqual(resolver.bundleID, "com.test.bundle", file: file, line: line) let resolverResult = resolver.resolve(.unresolved(UnresolvedTopicReference(topicURL: ValidatedURL(parsingExact: "doc://com.test.bundle/something")!))) guard case .failure(_, let error) = resolverResult else { XCTFail("Encountered an unexpected type of error.", file: file, line: line) @@ -674,7 +674,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { XCTAssert(FileManager.default.isExecutableFile(atPath: executableLocation.path)) let resolver = try OutOfProcessReferenceResolver(processLocation: executableLocation, errorOutputHandler: { _ in }) - XCTAssertEqual(resolver.id, "com.test.bundle") + XCTAssertEqual(resolver.bundleID, "com.test.bundle") XCTAssertThrowsError(try resolver.resolveInformationForTopicURL(URL(string: "doc://com.test.bundle/something")!)) { guard case OutOfProcessReferenceResolver.Error.executableSentBundleIdentifierAgain = $0 else { @@ -720,7 +720,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { ) let resolver = try makeResolver(testMetadata) - XCTAssertEqual(resolver.id, "com.test.bundle", file: file, line: line) + XCTAssertEqual(resolver.bundleID, "com.test.bundle", file: file, line: line) // Resolve the reference let unresolved = TopicReference.unresolved( diff --git a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift index 94400fd31..c2d3ccc46 100644 --- a/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/SemanticAnalyzerTests.swift @@ -57,7 +57,7 @@ class SemanticAnalyzerTests: XCTestCase { func testDoNotCrashOnInvalidContent() throws { let (bundle, context) = try loadBundle(catalog: catalogHierarchy) - XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(id: bundle.id, path: "/Oops", sourceLanguage: .swift))) + XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/Oops", sourceLanguage: .swift))) } func testWarningsAboutDirectiveSupport() throws { From f97e6d39751715fcac3bee38caab181c60e6ac3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 21 Nov 2024 13:52:51 +0100 Subject: [PATCH 16/17] Use `bundleID` instead of `id` for property names outside the bundle --- .../Convert/ConvertService.swift | 2 +- .../Infrastructure/DocumentationContext.swift | 18 +++++++++--------- .../OutOfProcessReferenceResolver.swift | 6 +++--- .../OutOfProcessReferenceResolverTests.swift | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift index 0ca8a3cc3..3def895ca 100644 --- a/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift +++ b/Sources/SwiftDocC/DocumentationService/Convert/ConvertService.swift @@ -128,7 +128,7 @@ public struct ConvertService: DocumentationService { if let linkResolvingServer { let resolver = try OutOfProcessReferenceResolver( - id: request.bundleInfo.id, + bundleID: request.bundleInfo.id, server: linkResolvingServer, convertRequestIdentifier: messageIdentifier ) diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index 7a03a73c7..05f3ae302 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -1799,10 +1799,10 @@ public class DocumentationContext { /// Returns a list of all the image assets that registered for a given `bundleIdentifier`. /// - /// - Parameter id: The identifier of the bundle to return image assets for. + /// - Parameter bundleID: The identifier of the bundle to return image assets for. /// - Returns: A list of all the image assets for the given bundle. - public func registeredImageAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { - registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: id) + public func registeredImageAssets(for bundleID: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(withExtensions: DocumentationContext.supportedImageExtensions, forBundleID: bundleID) } @available(*, deprecated, renamed: "registeredImageAssets(for:)", message: "registeredImageAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") @@ -1812,10 +1812,10 @@ public class DocumentationContext { /// Returns a list of all the video assets that registered for a given `bundleIdentifier`. /// - /// - Parameter id: The identifier of the bundle to return video assets for. + /// - Parameter bundleID: The identifier of the bundle to return video assets for. /// - Returns: A list of all the video assets for the given bundle. - public func registeredVideoAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { - registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: id) + public func registeredVideoAssets(for bundleID: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(withExtensions: DocumentationContext.supportedVideoExtensions, forBundleID: bundleID) } @available(*, deprecated, renamed: "registeredVideoAssets(for:)", message: "registeredImageAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") @@ -1825,10 +1825,10 @@ public class DocumentationContext { /// Returns a list of all the download assets that registered for a given `bundleIdentifier`. /// - /// - Parameter id: The identifier of the bundle to return download assets for. + /// - Parameter bundleID: The identifier of the bundle to return download assets for. /// - Returns: A list of all the download assets for the given bundle. - public func registeredDownloadsAssets(for id: DocumentationBundle.Identifier) -> [DataAsset] { - registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: id) + public func registeredDownloadsAssets(for bundleID: DocumentationBundle.Identifier) -> [DataAsset] { + registeredAssets(inContexts: [DataAsset.Context.download], forBundleID: bundleID) } @available(*, deprecated, renamed: "registeredDownloadsAssets(for:)", message: "registeredDownloadsAssets(for:)' instead. This deprecated API will be removed after 6.2 is released") diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index b21acc1f7..add1ff480 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -98,11 +98,11 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE /// The documentation service is expected to be able to handle messages of kind "resolve-reference". /// /// - Parameters: - /// - id: The bundle identifier the server can resolve references for. + /// - bundleID: The bundle identifier the server can resolve references for. /// - server: The server to send link resolution requests to. /// - convertRequestIdentifier: The identifier that the resolver will use for convert requests that it sends to the server. - public init(id: DocumentationBundle.Identifier, server: DocumentationServer, convertRequestIdentifier: String?) throws { - self.bundleID = id + public init(bundleID: DocumentationBundle.Identifier, server: DocumentationServer, convertRequestIdentifier: String?) throws { + self.bundleID = bundleID self.externalLinkResolvingClient = LongRunningService( server: server, convertRequestIdentifier: convertRequestIdentifier) } diff --git a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift index 296ef973e..6d4039e04 100644 --- a/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift @@ -197,7 +197,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - id: "com.test.bundle", + bundleID: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) @@ -393,7 +393,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - id: "com.test.bundle", + bundleID: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) @@ -495,7 +495,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) let resolver = try OutOfProcessReferenceResolver( - id: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id") + bundleID: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id") try assertForwardsResolverErrors(resolver: resolver) } @@ -826,7 +826,7 @@ class OutOfProcessReferenceResolverTests: XCTestCase { }) return try OutOfProcessReferenceResolver( - id: "com.test.bundle", + bundleID: "com.test.bundle", server: server, convertRequestIdentifier: "convert-id" ) From 9478d474d8d0a019b68e34d4ebe877cc740fe4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 21 Nov 2024 13:55:31 +0100 Subject: [PATCH 17/17] Use "bundle id" in local variable in fallback resolver --- .../Infrastructure/Link Resolution/LinkResolver.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index 6896f23d4..7b98467cb 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -169,10 +169,10 @@ private final class FallbackResolverBasedLinkResolver { private func resolve(_ unresolvedReference: UnresolvedTopicReference, in parent: ResolvedTopicReference, fromSymbolLink isCurrentlyResolvingSymbolLink: Bool, context: DocumentationContext) -> TopicReferenceResolutionResult? { // Check if a fallback reference resolver should resolve this - let referenceID = unresolvedReference.bundleID ?? parent.bundleID + let referenceBundleID = unresolvedReference.bundleID ?? parent.bundleID guard let fallbackResolver = context.configuration.convertServiceConfiguration.fallbackResolver, // This uses an underscored internal variant of `registeredBundles` to avoid deprecation warnings and remain compatible with legacy data providers. - let knownBundleID = context._registeredBundles.first(where: { $0.id == referenceID || urlReadablePath($0.displayName) == referenceID.rawValue })?.id, + let knownBundleID = context._registeredBundles.first(where: { $0.id == referenceBundleID || urlReadablePath($0.displayName) == referenceBundleID.rawValue })?.id, fallbackResolver.bundleID == knownBundleID else { return nil @@ -184,7 +184,7 @@ private final class FallbackResolverBasedLinkResolver { var allCandidateURLs = [URL]() let alreadyResolved = ResolvedTopicReference( - bundleID: referenceID, + bundleID: referenceBundleID, path: unresolvedReference.path.prependingLeadingSlash, fragment: unresolvedReference.topicURL.components.fragment, sourceLanguages: parent.sourceLanguages