Skip to content

Commit 2cc8b69

Browse files
authored
Mark automatic curation topic sections as "generated" in Render JSON (#749)
rdar://116584446
1 parent 3c30e2f commit 2cc8b69

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
795795
renderer: contentRenderer
796796
) {
797797
contentCompiler.collectedTopicReferences.append(contentsOf: seeAlso.references)
798-
seeAlsoSections.append(TaskGroupRenderSection(
799-
title: seeAlso.title,
800-
abstract: nil,
801-
discussion: nil,
802-
identifiers: seeAlso.references.map { $0.absoluteString },
803-
generated: true
804-
))
798+
seeAlsoSections.append(TaskGroupRenderSection(taskGroup: seeAlso))
805799
}
806800

807801
return seeAlsoSections
@@ -1531,12 +1525,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
15311525
guard !newReferences.isEmpty else { return nil }
15321526

15331527
contentCompiler.collectedTopicReferences.append(contentsOf: newReferences)
1534-
return TaskGroupRenderSection(
1535-
title: group.title,
1536-
abstract: nil,
1537-
discussion: nil,
1538-
identifiers: newReferences.map { $0.absoluteString }
1539-
)
1528+
return TaskGroupRenderSection(taskGroup: (title: group.title, references: newReferences))
15401529
})
15411530

15421531
// Place "bottom" rendering preference automatic task groups
@@ -1628,13 +1617,7 @@ public struct RenderNodeTranslator: SemanticVisitor {
16281617
), !seeAlso.references.isEmpty {
16291618
contentCompiler.collectedTopicReferences.append(contentsOf: seeAlso.references)
16301619
seeAlsoSections.append(
1631-
TaskGroupRenderSection(
1632-
title: seeAlso.title,
1633-
abstract: nil,
1634-
discussion: nil,
1635-
identifiers: seeAlso.references.map { $0.absoluteString },
1636-
generated: true
1637-
)
1620+
TaskGroupRenderSection(taskGroup: seeAlso)
16381621
)
16391622
}
16401623

Sources/SwiftDocC/Model/Rendering/Symbol/TaskGroupRenderSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension TaskGroupRenderSection {
9090
self.title = group.title
9191
self.abstract = nil
9292
self.identifiers = group.references.map({ $0.absoluteString })
93-
self.generated = false
93+
self.generated = true
9494
self.discussion = nil
9595
}
9696
}

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class AutomaticCurationTests: XCTestCase {
4141
var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference, source: nil)
4242
let renderNode = translator.visit(symbol) as! RenderNode
4343

44+
for section in renderNode.topicSections {
45+
XCTAssert(section.generated, "\((section.title ?? "").singleQuoted) was not marked as generated.")
46+
}
47+
4448
XCTAssertNotNil(renderNode.topicSections.first(where: { group -> Bool in
4549
return group.title == AutomaticCuration.groupTitle(for: kind)
4650
}), "\(kind.identifier) was not automatically curated in a \(AutomaticCuration.groupTitle(for: kind).singleQuoted) topic group. Please add it to either AutomaticCuration.groupKindOrder or KindIdentifier.noPageKinds." )
@@ -124,6 +128,13 @@ class AutomaticCurationTests: XCTestCase {
124128
// The manual topic section is listed before any automatic topic sections
125129
XCTAssertEqual(renderNode.topicSections.first?.title, "Manually curated")
126130

131+
if let firstSection = renderNode.topicSections.first {
132+
XCTAssertFalse(firstSection.generated, "The first topic section is manually authored.")
133+
}
134+
for section in renderNode.topicSections.dropFirst() {
135+
XCTAssert(section.generated, "The other topic sections are generated")
136+
}
137+
127138
// Check that the automatic topic sections only exist if its elements weren't manually curated
128139
XCTAssertEqual(
129140
!curatedIndices.contains(0),

0 commit comments

Comments
 (0)