Skip to content

Commit b582adb

Browse files
committed
Fix API Collection icon rendering for external references
Ensures API Collections are correctly identified as collectionGroup kind in linkable entities by using DocumentationContentRenderer.roleForArticle logic. This fixes cross-framework references where API Collections were incorrectly showing Article icons instead of Collection Group icons. rdar://135837611
1 parent f8d69d9 commit b582adb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,18 @@ private extension DocumentationNode {
10171017
// specialized articles, like sample code pages, that benefit from being treated as articles in
10181018
// some parts of the compilation process (like curation) but not others (like link destination
10191019
// summary creation and render node translation).
1020-
return metadata?.pageKind?.kind.documentationNodeKind ?? kind
1020+
let baseKind = metadata?.pageKind?.kind.documentationNodeKind ?? kind
1021+
1022+
// For articles, check if they should be treated as API Collections (collectionGroup).
1023+
// This ensures that linkable entities have the same kind detection logic as the rendering system,
1024+
// fixing cross-framework references where API Collections were incorrectly showing as articles.
1025+
if baseKind == .article,
1026+
let article = semantic as? Article,
1027+
DocumentationContentRenderer.roleForArticle(article, nodeKind: kind) == .collectionGroup {
1028+
return .collectionGroup
1029+
}
1030+
1031+
return baseKind
10211032
}
10221033
}
10231034

Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,6 @@ class LinkDestinationSummaryTests: XCTestCase {
833833
/// Tests that API Collections (articles with Topics sections) are correctly identified as `.collectionGroup`
834834
/// kind in linkable entities, ensuring cross-framework references display the correct icon.
835835
func testAPICollectionKindForLinkDestinationSummary() async throws {
836-
throw XCTSkip("Test will be enabled after implementing the fix")
837-
838836
let symbolGraph = makeSymbolGraph(
839837
moduleName: "TestModule",
840838
symbols: [makeSymbol(id: "test-class", kind: .class, pathComponents: ["TestClass"])]

0 commit comments

Comments
 (0)