Skip to content

Commit b385a24

Browse files
committed
Fix API Collection icon rendering for external references
Implements detection of API Collections in external references by checking for task groups in LinkDestinationSummary. Articles with task groups are treated as API Collections and get collectionGroup role for correct icon display. Removes test skip to enable validation of the fix. rdar://135837611
1 parent 58d32f9 commit b385a24

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ extension LinkDestinationSummary {
165165

166166
/// Create a topic render render reference for this link summary and its content variants.
167167
func makeTopicRenderReference() -> TopicRenderReference {
168-
let (kind, role) = DocumentationContentRenderer.renderKindAndRole(kind, semantic: nil)
168+
let (kind, role) = DocumentationContentRenderer.renderKindAndRole(kind, semantic: nil, linkSummary: self)
169169

170170
var titleVariants = VariantCollection(defaultValue: title)
171171
var abstractVariants = VariantCollection(defaultValue: abstract ?? [])

Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public class DocumentationContentRenderer {
247247
return true
248248
}
249249

250-
static func renderKindAndRole(_ kind: DocumentationNode.Kind?, semantic: Semantic?) -> (RenderNode.Kind, String) {
250+
static func renderKindAndRole(_ kind: DocumentationNode.Kind?, semantic: Semantic? = nil, linkSummary: LinkDestinationSummary? = nil) -> (RenderNode.Kind, String) {
251251
guard let kind else {
252252
return (.article, role(for: .article).rawValue)
253253
}
@@ -270,6 +270,9 @@ public class DocumentationContentRenderer {
270270
default:
271271
if let article = semantic as? Article {
272272
return (.article, roleForArticle(article, nodeKind: kind).rawValue)
273+
} else if kind == .article, let summary = linkSummary, summary.taskGroups != nil {
274+
// For external references: Articles with task groups are API Collections and should have collectionGroup role
275+
return (.article, Self.role(for: .collectionGroup).rawValue)
273276
} else {
274277
return (.article, role)
275278
}

Tests/SwiftDocCTests/Rendering/DocumentationContentRendererTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ class DocumentationContentRendererTests: XCTestCase {
133133
}
134134

135135
func testRenderKindAndRoleForAPICollection() throws {
136-
throw XCTSkip("TDD: Temporarily disabled while implementing API Collection icon fix")
137-
138136
// Articles with task groups should get collectionGroup role for external references
139137
let apiCollectionSummary = LinkDestinationSummary(
140138
kind: .article,

0 commit comments

Comments
 (0)