-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine logic for when curation removes a symbol from automatic curati…
…on (#1075) * Refine logic for when curation removes a symbol from automatic curation rdar://133338975 * Update curation in MixedManualAutomaticCuration to follow new logic * Update tests to expect automatic curation of symbols that are manually curated outside their canonical container * Fix bug where automatic overload topic groups could include unexpected symbols * Stop using TopicGraph to find the overloads in a group * Documentation that organizing member symbols outside their canonical container doesn't remove them from the default topic group. * Add tip about dividing large topics into sub-topics Also, remove member symbol from top-level symbol curation example * Minor grammar correction in code comment Co-authored-by: Andrea Fernandez Buitrago <[email protected]> * Address code review feedback: - Update reference to topic graph node property in code comment * Address code review feedback: - Rephrase public documentation about curating a symbol outside its canonical container --------- Co-authored-by: Andrea Fernandez Buitrago <[email protected]>
- Loading branch information
1 parent
be887df
commit 50c9904
Showing
24 changed files
with
693 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...s/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Overloads.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Foundation | ||
import SymbolKit | ||
|
||
extension PathHierarchyBasedLinkResolver { | ||
|
||
/// Returns the references for the overloaded symbols that belong to the given overload group. | ||
/// - Parameter reference: The reference of an overload group. | ||
/// - Returns: The references for overloaded symbols in the given group, or `nil` if the `reference` is not an overload group reference. | ||
func overloads(ofGroup reference: ResolvedTopicReference) -> [ResolvedTopicReference]? { | ||
guard let groupNodeID = resolvedReferenceMap[reference] else { return nil } | ||
let groupNode = pathHierarchy.lookup[groupNodeID]! // Only the path hierarchy can create its IDs and a created ID always matches a node | ||
|
||
guard let groupSymbol = groupNode.symbol, groupSymbol.isOverloadGroup else { | ||
return nil | ||
} | ||
assert(groupNode.languages == [.swift], "Only Swift supports overload groups. The implementation makes assumptions based on this.") | ||
|
||
let elementsWithSameName = groupNode.parent?.children[groupNode.name]?.storage ?? [] | ||
|
||
let groupSymbolKindID = groupSymbol.kind.identifier | ||
return elementsWithSameName.compactMap { | ||
let id = $0.node.identifier | ||
guard id != groupNodeID, // Skip the overload group itself | ||
$0.node.symbol?.kind.identifier == groupSymbolKindID // Only symbols of the same kind as the group are overloads | ||
else { | ||
return nil | ||
} | ||
|
||
assert( | ||
// The PathHierarchy doesn't track overloads (and I don't think it should) but we can check that the filtered elements | ||
// have the behaviors that's expected of overloaded symbols as a proxy to verify that no unexpected values are returned. | ||
$0.node.specialBehaviors == [.disfavorInLinkCollision, .excludeFromAutomaticCuration], | ||
""" | ||
Node behaviors \($0.node.specialBehaviors) for \($0.node.symbol?.identifier.precise ?? "<non-symbol>") doesn't match an \ | ||
overloaded symbol's behaviors (\(PathHierarchy.Node.SpecialBehaviors(arrayLiteral: [.disfavorInLinkCollision, .excludeFromAutomaticCuration]))) | ||
""" | ||
) | ||
|
||
return resolvedReferenceMap[$0.node.identifier] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.