Skip to content

Commit 04a26fb

Browse files
authored
Revert support for module-relative documentation extension links (#574) (#575)
rdar://108666088
1 parent d18f340 commit 04a26fb

File tree

2 files changed

+2
-56
lines changed

2 files changed

+2
-56
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,18 +1335,9 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
13351335
}
13361336

13371337
if LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver {
1338-
// If there's a single module then resolve relative to the module symbol. Otherwise resolve relative to the bundle root.
1339-
// This means that links can omit the module name if there's only one module but need to start with the module name if there are multiple modules.
1340-
let rootReference: ResolvedTopicReference
1341-
let moduleReferences = hierarchyBasedLinkResolver!.modules()
1342-
if moduleReferences.count == 1 {
1343-
rootReference = moduleReferences.first!
1344-
} else {
1345-
rootReference = bundle.rootReference
1346-
}
1347-
1338+
// FIXME: Resolve the link relative to the module https://github.com/apple/swift-docc/issues/516
13481339
let reference = TopicReference.unresolved(.init(topicURL: url))
1349-
switch resolve(reference, in: rootReference, fromSymbolLink: true) {
1340+
switch resolve(reference, in: bundle.rootReference, fromSymbolLink: true) {
13501341
case .success(let resolved):
13511342
if let existing = uncuratedDocumentationExtensions[resolved] {
13521343
if symbolsWithMultipleDocumentationExtensionMatches[resolved] == nil {

Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,51 +3040,6 @@ let expected = """
30403040
}
30413041
}
30423042

3043-
func testMatchesDocumentationExtensionsRelativeToModule() throws {
3044-
try XCTSkipUnless(LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver)
3045-
3046-
let (_, bundle, context) = try testBundleAndContext(copying: "MixedLanguageFrameworkWithLanguageRefinements") { url in
3047-
// Top level symbols, omitting the module name
3048-
try """
3049-
# ``MyStruct/myStructProperty``
3050-
3051-
@Metadata {
3052-
@DocumentationExtension(mergeBehavior: override)
3053-
}
3054-
3055-
my struct property
3056-
""".write(to: url.appendingPathComponent("struct-property.md"), atomically: true, encoding: .utf8)
3057-
3058-
try """
3059-
# ``MyTypeAlias``
3060-
3061-
@Metadata {
3062-
@DocumentationExtension(mergeBehavior: override)
3063-
}
3064-
3065-
my type alias
3066-
""".write(to: url.appendingPathComponent("alias.md"), atomically: true, encoding: .utf8)
3067-
}
3068-
3069-
do {
3070-
// The resolved reference needs more disambiguation than the documentation extension link did.
3071-
let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyStruct/myStructProperty", sourceLanguage: .swift)
3072-
3073-
let node = try context.entity(with: reference)
3074-
let symbol = try XCTUnwrap(node.semantic as? Symbol)
3075-
XCTAssertEqual(symbol.abstract?.plainText, "my struct property", "The abstract should be from the overriding documentation extension.")
3076-
}
3077-
3078-
do {
3079-
// The resolved reference needs more disambiguation than the documentation extension link did.
3080-
let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MixedFramework/MyTypeAlias", sourceLanguage: .swift)
3081-
3082-
let node = try context.entity(with: reference)
3083-
let symbol = try XCTUnwrap(node.semantic as? Symbol)
3084-
XCTAssertEqual(symbol.abstract?.plainText, "my type alias", "The abstract should be from the overriding documentation extension.")
3085-
}
3086-
}
3087-
30883043
func testMultipleDocumentationExtensionMatchDiagnostic() throws {
30893044
try XCTSkipUnless(LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver)
30903045

0 commit comments

Comments
 (0)