Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension PathHierarchy {
}
}
}
let topLevelNames = Set(modules.map(\.name) + [articlesContainer.name, tutorialContainer.name])
let topLevelNames = Set(modules.map(\.name) + (onlyFindSymbols ? [] : [articlesContainer.name, tutorialContainer.name]))

if isAbsolute, FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled {
throw Error.moduleNotFound(
Expand Down
26 changes: 26 additions & 0 deletions Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,32 @@ class PathHierarchyTests: XCTestCase {
XCTAssert(overloadedProtocolMethod.symbol?.identifier.precise.hasSuffix(SymbolGraph.Symbol.overloadGroupIdentifierSuffix) == true)
}

func testDoesNotSuggestBundleNameForSymbolLink() throws {
let exampleDocumentation = Folder(name: "Something.docc", content: [
JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph(moduleName: "ModuleName")),

InfoPlist(displayName: "ModuleNaem"), // The bundle name is intentionally misspelled.

// The symbol link in the header is intentionally misspelled.
TextFile(name: "root.md", utf8Content: """
# ``ModuleNaem``

A documentation extension file with a misspelled link that happens to match the, also misspelled, bundle name.
"""),
])
let catalogURL = try exampleDocumentation.write(inside: createTemporaryDirectory())
let (_, _, context) = try loadBundle(from: catalogURL)
let tree = context.linkResolver.localResolver.pathHierarchy

// This link is intentionally misspelled
try assertPathRaisesErrorMessage("ModuleNaem", in: tree, context: context, expectedErrorMessage: "Can't resolve 'ModuleNaem'") { errorInfo in
XCTAssertEqual(errorInfo.solutions.map(\.summary), ["Replace 'ModuleNaem' with 'ModuleName'"])
}

let linkProblem = try XCTUnwrap(context.problems.first(where: { $0.diagnostic.summary == "No symbol matched 'ModuleNaem'. Can't resolve 'ModuleNaem'."}))
XCTAssertEqual(linkProblem.possibleSolutions.map(\.summary), ["Replace 'ModuleNaem' with 'ModuleName'"])
}

func testSymbolsWithSameNameAsModule() throws {
let (_, context) = try testBundleAndContext(named: "SymbolsWithSameNameAsModule")
let tree = context.linkResolver.localResolver.pathHierarchy
Expand Down