From e96fa7a513459f40f57207cb8116e7c9014e2ccd Mon Sep 17 00:00:00 2001 From: Andrea Fernandez Buitrago <15234535+anferbui@users.noreply.github.com> Date: Thu, 13 Nov 2025 13:47:58 +0000 Subject: [PATCH 1/2] Add missing fields in Equatable implementation The `Equatable` implementation of `LinkDestinationSummary` was missing some of the new fields which were added recently. This commit adds them. --- Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index 5c3af1ff6..ab6e2feb9 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -112,7 +112,8 @@ public struct LinkDestinationSummary: Codable, Equatable { // so that external documentation sources don't need to provide that data. // Adding new required properties is considered breaking change since existing external documentation sources // wouldn't necessarily meet these new requirements. - + // Make sure to update the encoding, decoding and Equatable implementations when adding new properties. + /// A collection of identifiers that all relate to some common task, as described by the title. public struct TaskGroup: Codable, Equatable { /// The title of this task group @@ -935,12 +936,15 @@ extension LinkDestinationSummary { guard lhs.kind == rhs.kind else { return false } guard lhs.language == rhs.language else { return false } guard lhs.relativePresentationURL == rhs.relativePresentationURL else { return false } + guard lhs.absolutePresentationURL == rhs.absolutePresentationURL else { return false } guard lhs.title == rhs.title else { return false } guard lhs.abstract == rhs.abstract else { return false } guard lhs.availableLanguages == rhs.availableLanguages else { return false } guard lhs.platforms == rhs.platforms else { return false } guard lhs.taskGroups == rhs.taskGroups else { return false } + guard lhs.plainTextDeclaration == rhs.plainTextDeclaration else { return false } guard lhs.subheadingDeclarationFragments == rhs.subheadingDeclarationFragments else { return false } + guard lhs.navigatorDeclarationFragments == rhs.navigatorDeclarationFragments else { return false } guard lhs.redirects == rhs.redirects else { return false } guard lhs.topicImages == rhs.topicImages else { return false } guard lhs.variants == rhs.variants else { return false } From 40805b00762948b7152484e9ebb6f61d5eab455a Mon Sep 17 00:00:00 2001 From: Andrea Fernandez Buitrago <15234535+anferbui@users.noreply.github.com> Date: Thu, 13 Nov 2025 12:14:30 +0000 Subject: [PATCH 2/2] Encode absolute presentation URL if present Support for absolute URLs in link summaries was added in 7db36ad21303f2b85c094b7add3023b4c9e1111e. It added support for absolute URLs when decoding a link summary, but not when encoding it: https://github.com/swiftlang/swift-docc/blob/cfcd96f0e992af2287661f6a26e8398096f6bc1e/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift#L772-L773 https://github.com/swiftlang/swift-docc/blob/cfcd96f0e992af2287661f6a26e8398096f6bc1e/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift#L728 Both are needed when using an external link resolver, as the external link resolver needs to encode the entity to send to DocC. Fixes rdar://164628218. --- Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift | 2 +- .../Infrastructure/ExternalReferenceResolverTests.swift | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index ab6e2feb9..993e8fb31 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -726,7 +726,7 @@ extension LinkDestinationSummary { } else { try container.encode(kind, forKey: .kind) } - try container.encode(relativePresentationURL, forKey: .relativePresentationURL) + try container.encode(absolutePresentationURL ?? relativePresentationURL, forKey: .relativePresentationURL) try container.encode(referenceURL, forKey: .referenceURL) try container.encode(title, forKey: .title) try container.encodeIfPresent(abstract, forKey: .abstract) diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index a5aae2312..d4a10d31d 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -1420,7 +1420,10 @@ class ExternalReferenceResolverTests: XCTestCase { """.utf8)) XCTAssertEqual(externalEntity.relativePresentationURL.absoluteString, "/path/to/something") XCTAssertEqual(externalEntity.absolutePresentationURL?.absoluteString, "https://com.example/path/to/something") - + + // Test that encoding the link summary preserves the absolute URL + try assertRoundTripCoding(externalEntity) + let resolver = Resolver(entityToReturn: externalEntity) var configuration = DocumentationContext.Configuration()