@@ -598,7 +598,8 @@ public struct RenderNodeTranslator: SemanticVisitor {
598598
599599 public mutating func visitArticle( _ article: Article ) -> RenderTree ? {
600600 var node = RenderNode ( identifier: identifier, kind: . article)
601- var contentCompiler = RenderContentCompiler ( context: context, bundle: bundle, identifier: identifier)
601+ // Contains symbol references declared in the Topics section.
602+ var topicSectionContentCompiler = RenderContentCompiler ( context: context, bundle: bundle, identifier: identifier)
602603
603604 node. metadata. title = article. title!. plainText
604605
@@ -674,7 +675,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
674675 allowExternalLinks: false ,
675676 allowedTraits: allowedTraits,
676677 availableTraits: documentationNode. availableVariantTraits,
677- contentCompiler: & contentCompiler
678+ contentCompiler: & topicSectionContentCompiler
678679 )
679680 )
680681 }
@@ -685,7 +686,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
685686 sections. append (
686687 contentsOf: renderAutomaticTaskGroupsSection (
687688 article. automaticTaskGroups. filter { $0. renderPositionPreference == . top } ,
688- contentCompiler: & contentCompiler
689+ contentCompiler: & topicSectionContentCompiler
689690 )
690691 )
691692 }
@@ -714,7 +715,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
714715 }
715716
716717 // Collect all child topic references.
717- contentCompiler . collectedTopicReferences. append ( contentsOf: groups. flatMap ( \. references) )
718+ topicSectionContentCompiler . collectedTopicReferences. append ( contentsOf: groups. flatMap ( \. references) )
718719 // Add the final groups to the node.
719720 sections. append ( contentsOf: groups. map ( TaskGroupRenderSection . init ( taskGroup: ) ) )
720721 }
@@ -725,7 +726,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
725726 sections. append (
726727 contentsOf: renderAutomaticTaskGroupsSection (
727728 article. automaticTaskGroups. filter { $0. renderPositionPreference == . bottom } ,
728- contentCompiler: & contentCompiler
729+ contentCompiler: & topicSectionContentCompiler
729730 )
730731 )
731732 }
@@ -736,11 +737,30 @@ public struct RenderNodeTranslator: SemanticVisitor {
736737 node. topicSectionsStyle = topicsSectionStyle ( for: documentationNode)
737738
738739 if shouldCreateAutomaticRoleHeading ( for: documentationNode) {
739- if node. topicSections. isEmpty {
740- // Set an eyebrow for articles
740+
741+ let role = DocumentationContentRenderer . roleForArticle ( article, nodeKind: documentationNode. kind)
742+ node. metadata. role = role. rawValue
743+
744+ switch role {
745+ case . article:
746+ // If there are no links to other nodes from the article,
747+ // set the eyebrow for articles.
741748 node. metadata. roleHeading = " Article "
749+ case . collectionGroup:
750+ // If the article links to other nodes, set the eyebrow for
751+ // API Collections if any linked node is a symbol.
752+ //
753+ // If none of the linked nodes are symbols (it's a plain collection),
754+ // don't display anything as the eyebrow title.
755+ let curatesSymbols = topicSectionContentCompiler. collectedTopicReferences. contains { topicReference in
756+ context. topicGraph. nodeWithReference ( topicReference) ? . kind. isSymbol ?? false
757+ }
758+ if curatesSymbols {
759+ node. metadata. roleHeading = " API Collection "
760+ }
761+ default :
762+ break
742763 }
743- node. metadata. role = DocumentationContentRenderer . roleForArticle ( article, nodeKind: documentationNode. kind) . rawValue
744764 }
745765
746766 if let pageImages = documentationNode. metadata? . pageImages {
@@ -780,7 +800,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
780800 allowExternalLinks: true ,
781801 allowedTraits: allowedTraits,
782802 availableTraits: documentationNode. availableVariantTraits,
783- contentCompiler: & contentCompiler
803+ contentCompiler: & topicSectionContentCompiler
784804 )
785805 )
786806 }
@@ -794,7 +814,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
794814 renderContext: renderContext,
795815 renderer: contentRenderer
796816 ) {
797- contentCompiler . collectedTopicReferences. append ( contentsOf: seeAlso. references)
817+ topicSectionContentCompiler . collectedTopicReferences. append ( contentsOf: seeAlso. references)
798818 seeAlsoSections. append ( TaskGroupRenderSection ( taskGroup: seeAlso) )
799819 }
800820
@@ -845,7 +865,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
845865 node. metadata. roleHeading = titleHeading. heading
846866 }
847867
848- collectedTopicReferences. append ( contentsOf: contentCompiler . collectedTopicReferences)
868+ collectedTopicReferences. append ( contentsOf: topicSectionContentCompiler . collectedTopicReferences)
849869 node. references = createTopicRenderReferences ( )
850870
851871 addReferences ( imageReferences, to: & node)
@@ -854,7 +874,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
854874 addReferences ( downloadReferences, to: & node)
855875 // See Also can contain external links, we need to separately transfer
856876 // link references from the content compiler
857- addReferences ( contentCompiler . linkReferences, to: & node)
877+ addReferences ( topicSectionContentCompiler . linkReferences, to: & node)
858878
859879 return node
860880 }
0 commit comments