@@ -1133,6 +1133,30 @@ class PathHierarchyTests: XCTestCase {
1133
1133
XCTAssertNil ( articleNode. symbol, " General documentation link find the article " )
1134
1134
}
1135
1135
1136
+ func testArticleSelfAnchorLinks( ) throws {
1137
+ try XCTSkipUnless ( LinkResolutionMigrationConfiguration . shouldUseHierarchyBasedLinkResolver)
1138
+ let ( _, _, context) = try testBundleAndContext ( copying: " MixedLanguageFramework " ) { url in
1139
+ try """
1140
+ # ArticleWithHeading
1141
+
1142
+ ## TestTargetHeading
1143
+
1144
+ This article has the same path as a symbol. See also:
1145
+ - <doc:TestTargetHeading>
1146
+ - <doc:#TestTargetHeading>
1147
+
1148
+ """ . write ( to: url. appendingPathComponent ( " ArticleWithHeading.md " ) , atomically: true , encoding: . utf8)
1149
+ }
1150
+
1151
+ let tree = try XCTUnwrap ( context. hierarchyBasedLinkResolver? . pathHierarchy)
1152
+ let articleNode = try tree. findNode ( path: " /MixedLanguageFramework/ArticleWithHeading " , onlyFindSymbols: false )
1153
+
1154
+ let linkNode = try tree. find ( path: " TestTargetHeading " , parent: articleNode. identifier, onlyFindSymbols: false )
1155
+ let anchorLinkNode = try tree. find ( path: " #TestTargetHeading " , parent: articleNode. identifier, onlyFindSymbols: false )
1156
+ XCTAssertNotNil ( linkNode)
1157
+ XCTAssertNotNil ( anchorLinkNode)
1158
+ }
1159
+
1136
1160
func testOverloadedSymbols( ) throws {
1137
1161
try XCTSkipUnless ( LinkResolutionMigrationConfiguration . shouldUseHierarchyBasedLinkResolver)
1138
1162
let ( _, context) = try testBundleAndContext ( named: " OverloadedSymbols " )
@@ -1555,6 +1579,7 @@ class PathHierarchyTests: XCTestCase {
1555
1579
assertParsedPathComponents ( " first/ " , [ ( " first " , nil , nil ) ] )
1556
1580
assertParsedPathComponents ( " first//second " , [ ( " first " , nil , nil ) , ( " second " , nil , nil ) ] )
1557
1581
assertParsedPathComponents ( " first/second#third " , [ ( " first " , nil , nil ) , ( " second " , nil , nil ) , ( " third " , nil , nil ) ] )
1582
+ assertParsedPathComponents ( " #first " , [ ( " first " , nil , nil ) ] )
1558
1583
1559
1584
// Check disambiguation
1560
1585
assertParsedPathComponents ( " path-hash " , [ ( " path " , nil , " hash " ) ] )
0 commit comments