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 @@ -155,18 +155,10 @@ public extension Collection where Element: DocCSymbolRepresentable {
// Disambiguate by kind
return map { currentSymbol in
let kindCount = filter { $0.kindIdentifier == currentSymbol.kindIdentifier }.count

if LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver {
return (
shouldAddIdHash: kindCount > 1,
shouldAddKind: kindCount == 1
)
} else {
return (
shouldAddIdHash: kindCount > 1,
shouldAddKind: true
)
}
return (
shouldAddIdHash: kindCount > 1,
shouldAddKind: kindCount == 1
)
}
}
}
Expand Down
495 changes: 97 additions & 398 deletions Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Sources/SwiftDocC/Infrastructure/DocumentationConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ public struct DocumentationConverter: DocumentationConverterProtocol {
benchmark(add: Benchmark.ExternalTopicsHash(context: context))
// Log the peak memory.
benchmark(add: Benchmark.PeakMemory())

context.linkResolutionMismatches.reportGatheredMismatchesIfEnabled()

return (analysisProblems: context.problems, conversionProblems: conversionProblems)
}
Expand Down
5 changes: 1 addition & 4 deletions Sources/SwiftDocC/Infrastructure/DocumentationCurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ struct DocumentationCurator {
context.topicGraph.addNode(curatedNode)

// Move the article from the article cache to the documentation

if let hierarchyBasedLinkResolver = context.hierarchyBasedLinkResolver {
hierarchyBasedLinkResolver.addArticle(filename: articleFilename, reference: reference, anchorSections: documentationNode.anchorSections)
}
context.hierarchyBasedLinkResolver.addArticle(filename: articleFilename, reference: reference, anchorSections: documentationNode.anchorSections)

context.documentationCache[reference] = documentationNode
for anchor in documentationNode.anchorSections {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ private extension PathHierarchy.Node {
return context.nodeWithSymbolIdentifier(symbol.identifier.precise)!.name.description
}
// This only gets called for PathHierarchy error messages, so hierarchyBasedLinkResolver is never nil.
let reference = context.hierarchyBasedLinkResolver!.resolvedReferenceMap[identifier]!
let reference = context.hierarchyBasedLinkResolver.resolvedReferenceMap[identifier]!
if reference.fragment != nil {
return context.nodeAnchorSections[reference]!.title
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ enum GeneratedDocumentationTopics {
let inheritedSection = AutomaticTaskGroupSection(title: defaultImplementationGroupTitle, references: [collectionReference], renderPositionPreference: .bottom)
symbol.automaticTaskGroupsVariants[trait]?.append(inheritedSection)
}
if let hierarchyBasedLinkResolver = context.hierarchyBasedLinkResolver {
hierarchyBasedLinkResolver.addTaskGroup(named: title, reference: collectionReference, to: parent)
}
context.hierarchyBasedLinkResolver.addTaskGroup(named: title, reference: collectionReference, to: parent)
}
} else {
fatalError("createCollectionNode() should be used only to add nodes under symbols.")
Expand Down
5 changes: 0 additions & 5 deletions Sources/SwiftDocC/Semantics/ReferenceResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ func unresolvedReferenceProblem(reference: TopicReference, source: URL?, range:
[DiagnosticNote(source: $0, range: SourceLocation(line: 1, column: 1, source: $0)..<SourceLocation(line: 1, column: 1, source: $0), message: "This article was found but is not available for linking because it's uncurated")]
} ?? []

guard LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver else {
let diagnostic = Diagnostic(source: source, severity: severity, range: range, identifier: "org.swift.docc.unresolvedTopicReference", summary: "Topic reference \(reference.description.singleQuoted) couldn't be resolved. \(errorInfo.message)", notes: notes)
return Problem(diagnostic: diagnostic, possibleSolutions: [])
}

let referenceSourceRange: SourceRange? = range.map { range in
// FIXME: Finding the range for the link's destination is better suited for Swift-Markdown
// https://github.com/apple/swift-markdown/issues/109
Expand Down
12 changes: 2 additions & 10 deletions Tests/SwiftDocCTests/Diagnostics/DiagnosticTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,13 @@ class DiagnosticTests: XCTestCase {
// Resolve references
_ = resolver.visitMarkup(markup)

if LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver {
XCTAssertEqual(resolver.problems.first?.diagnostic.range, SourceLocation(line: 1, column: 10, source: nil)..<SourceLocation(line: 1, column: 19, source: nil))
} else {
XCTAssertEqual(resolver.problems.first?.diagnostic.range, SourceLocation(line: 1, column: 8, source: nil)..<SourceLocation(line: 1, column: 21, source: nil))
}
XCTAssertEqual(resolver.problems.first?.diagnostic.range, SourceLocation(line: 1, column: 10, source: nil)..<SourceLocation(line: 1, column: 19, source: nil))
let offset = SymbolGraph.LineList.SourceRange(start: .init(line: 10, character: 10), end: .init(line: 10, character: 20))

var problem = try XCTUnwrap(resolver.problems.first)
problem.offsetWithRange(offset)

if LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver {
XCTAssertEqual(problem.diagnostic.range, SourceLocation(line: 11, column: 20, source: nil)..<SourceLocation(line: 11, column: 29, source: nil))
} else {
XCTAssertEqual(problem.diagnostic.range, SourceLocation(line: 11, column: 18, source: nil)..<SourceLocation(line: 11, column: 31, source: nil))
}
XCTAssertEqual(problem.diagnostic.range, SourceLocation(line: 11, column: 20, source: nil)..<SourceLocation(line: 11, column: 29, source: nil))
}

func testFormattedDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,25 +482,18 @@ class ConvertServiceTests: XCTestCase {
"/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method"
)

if LinkResolutionMigrationConfiguration.shouldUseHierarchyBasedLinkResolver {
XCTAssertEqual(
renderNode.abstract?.first,
.reference(
identifier: .init("""
doc://identifier/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method
"""
),
isActive: true,
overridingTitle: nil,
overridingTitleInlineContent: nil
)
)
} else {
XCTAssertEqual(
renderNode.abstract?.first,
.codeVoice(code: "myFunction()")
XCTAssertEqual(
renderNode.abstract?.first,
.reference(
identifier: .init("""
doc://identifier/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method
"""
),
isActive: true,
overridingTitle: nil,
overridingTitleInlineContent: nil
)
}
)
}

let symbolGraphWithAdjustedLink = Data(
Expand Down
Loading