@@ -598,7 +598,8 @@ public struct RenderNodeTranslator: SemanticVisitor {
598
598
599
599
public mutating func visitArticle( _ article: Article ) -> RenderTree ? {
600
600
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)
602
603
603
604
node. metadata. title = article. title!. plainText
604
605
@@ -674,7 +675,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
674
675
allowExternalLinks: false ,
675
676
allowedTraits: allowedTraits,
676
677
availableTraits: documentationNode. availableVariantTraits,
677
- contentCompiler: & contentCompiler
678
+ contentCompiler: & topicSectionContentCompiler
678
679
)
679
680
)
680
681
}
@@ -685,7 +686,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
685
686
sections. append (
686
687
contentsOf: renderAutomaticTaskGroupsSection (
687
688
article. automaticTaskGroups. filter { $0. renderPositionPreference == . top } ,
688
- contentCompiler: & contentCompiler
689
+ contentCompiler: & topicSectionContentCompiler
689
690
)
690
691
)
691
692
}
@@ -714,7 +715,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
714
715
}
715
716
716
717
// Collect all child topic references.
717
- contentCompiler . collectedTopicReferences. append ( contentsOf: groups. flatMap ( \. references) )
718
+ topicSectionContentCompiler . collectedTopicReferences. append ( contentsOf: groups. flatMap ( \. references) )
718
719
// Add the final groups to the node.
719
720
sections. append ( contentsOf: groups. map ( TaskGroupRenderSection . init ( taskGroup: ) ) )
720
721
}
@@ -725,7 +726,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
725
726
sections. append (
726
727
contentsOf: renderAutomaticTaskGroupsSection (
727
728
article. automaticTaskGroups. filter { $0. renderPositionPreference == . bottom } ,
728
- contentCompiler: & contentCompiler
729
+ contentCompiler: & topicSectionContentCompiler
729
730
)
730
731
)
731
732
}
@@ -736,11 +737,30 @@ public struct RenderNodeTranslator: SemanticVisitor {
736
737
node. topicSectionsStyle = topicsSectionStyle ( for: documentationNode)
737
738
738
739
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.
741
748
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
742
763
}
743
- node. metadata. role = DocumentationContentRenderer . roleForArticle ( article, nodeKind: documentationNode. kind) . rawValue
744
764
}
745
765
746
766
if let pageImages = documentationNode. metadata? . pageImages {
@@ -780,7 +800,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
780
800
allowExternalLinks: true ,
781
801
allowedTraits: allowedTraits,
782
802
availableTraits: documentationNode. availableVariantTraits,
783
- contentCompiler: & contentCompiler
803
+ contentCompiler: & topicSectionContentCompiler
784
804
)
785
805
)
786
806
}
@@ -794,7 +814,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
794
814
renderContext: renderContext,
795
815
renderer: contentRenderer
796
816
) {
797
- contentCompiler . collectedTopicReferences. append ( contentsOf: seeAlso. references)
817
+ topicSectionContentCompiler . collectedTopicReferences. append ( contentsOf: seeAlso. references)
798
818
seeAlsoSections. append ( TaskGroupRenderSection ( taskGroup: seeAlso) )
799
819
}
800
820
@@ -845,7 +865,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
845
865
node. metadata. roleHeading = titleHeading. heading
846
866
}
847
867
848
- collectedTopicReferences. append ( contentsOf: contentCompiler . collectedTopicReferences)
868
+ collectedTopicReferences. append ( contentsOf: topicSectionContentCompiler . collectedTopicReferences)
849
869
node. references = createTopicRenderReferences ( )
850
870
851
871
addReferences ( imageReferences, to: & node)
@@ -854,7 +874,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
854
874
addReferences ( downloadReferences, to: & node)
855
875
// See Also can contain external links, we need to separately transfer
856
876
// link references from the content compiler
857
- addReferences ( contentCompiler . linkReferences, to: & node)
877
+ addReferences ( topicSectionContentCompiler . linkReferences, to: & node)
858
878
859
879
return node
860
880
}
0 commit comments