Skip to content

Commit 664acfd

Browse files
drop overload groups from curation if the overloads were manually curated (#913)
rdar://126273913
1 parent f390891 commit 664acfd

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ public struct AutomaticCuration {
9696
else {
9797
return
9898
}
99-
99+
100+
// If this symbol is an overload group and all its overloaded children were manually
101+
// curated elsewhere, skip it so it doesn't clutter the curation hierarchy with a
102+
// duplicate symbol.
103+
if let overloads = context.topicGraph.overloads(of: reference), overloads.isEmpty {
104+
return
105+
}
106+
100107
let childNode = try context.entity(with: reference)
101108
guard let childSymbol = childNode.semantic as? Symbol else {
102109
return

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,53 @@ class AutomaticCurationTests: XCTestCase {
737737
try assertAutomaticCuration(variants: [])
738738
try assertAutomaticCuration(variants: [.swift])
739739
}
740+
741+
func testAutomaticCurationDropsOverloadGroupWhenOverloadsAreCurated() throws {
742+
enableFeatureFlag(\.isExperimentalOverloadedSymbolPresentationEnabled)
743+
744+
let (_, bundle, context) = try testBundleAndContext(copying: "OverloadedSymbols") { url in
745+
try """
746+
# ``OverloadedProtocol``
747+
748+
This is a protocol's docs.
749+
750+
## Topics
751+
752+
- ``fourthTestMemberName(test:)-1h173``
753+
- ``fourthTestMemberName(test:)-8iuz7``
754+
- ``fourthTestMemberName(test:)-91hxs``
755+
- ``fourthTestMemberName(test:)-961zx``
756+
""".write(to: url.appendingPathComponent("OverloadedProtocol.md"), atomically: true, encoding: .utf8)
757+
}
758+
759+
let protocolDocumentationNode = try context.entity(
760+
with: .init(
761+
bundleIdentifier: bundle.identifier,
762+
path: "/documentation/ShapeKit/OverloadedProtocol",
763+
sourceLanguage: .swift))
764+
765+
// Compile the render node to flex the automatic curator
766+
let symbol = protocolDocumentationNode.semantic as! Symbol
767+
var translator = RenderNodeTranslator(
768+
context: context,
769+
bundle: bundle,
770+
identifier: protocolDocumentationNode.reference,
771+
source: nil)
772+
let renderNode = translator.visit(symbol) as! RenderNode
773+
774+
XCTAssertEqual(renderNode.topicSections.count, 1)
775+
776+
// The page should not contain a reference to the overload group node, which would otherwise
777+
// be automatically curated into an "Instance Methods" topic group with a hash suffix of 9b6be
778+
let curatedTopic = try XCTUnwrap(renderNode.topicSections.first)
779+
XCTAssertEqual(curatedTopic.title, nil)
780+
XCTAssertEqual(curatedTopic.identifiers, [
781+
"doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)-1h173",
782+
"doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)-8iuz7",
783+
"doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)-91hxs",
784+
"doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)-961zx",
785+
])
786+
}
740787
}
741788

742789
private func makeSymbol(

0 commit comments

Comments
 (0)