Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
.package(url: "https://github.com/apple/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/apple/swift-docc-symbolkit", branch: "main"),
// .package(url: "https://github.com/apple/swift-docc-symbolkit", branch: "main"),
.package(url: "https://github.com/QuietMisdreavus/swift-docc-symbolkit", branch: "6.0/combine-overload-groups"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "2.5.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.2.0"),
]
Expand Down
19 changes: 10 additions & 9 deletions Sources/SwiftDocC/Infrastructure/DocumentationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,6 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {

// For inherited symbols we remove the source docs (if inheriting docs is disabled) before creating their documentation nodes.
for (_, relationships) in unifiedSymbolGraph.relationshipsByLanguage {
var overloadGroups = [String: [String]]()

for relationship in relationships {
// Check for an origin key.
if let sourceOrigin = relationship[mixin: SymbolGraph.Relationship.SourceOrigin.self],
Expand All @@ -1176,15 +1174,18 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
localCache: documentationCache,
moduleName: moduleName
)
} else if relationship.kind == .overloadOf {
// An 'overloadOf' relationship points from symbol -> group
overloadGroups[relationship.target, default: []].append(relationship.source)
}
}

addOverloadGroupReferences(overloadGroups: overloadGroups)
}


let overloadGroups: [String: Set<String>] =
unifiedSymbolGraph.relationshipsByLanguage.values.flatMap({
$0.filter { $0.kind == .overloadOf }
}).reduce(into: [:], { acc, relationship in
acc[relationship.target, default: []].insert(relationship.source)
})
addOverloadGroupReferences(overloadGroups: overloadGroups)

if let rootURL = symbolGraphLoader.mainModuleURL(forModule: moduleName), let rootModule = unifiedSymbolGraph.moduleData[rootURL] {
addPreparedSymbolToContext(
preparedSymbolData(.init(fromSingleSymbol: moduleSymbol, module: rootModule, isMainGraph: true), reference: moduleReference, module: rootModule, moduleReference: moduleReference, fileURL: fileURL)
Expand Down Expand Up @@ -2395,7 +2396,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
return automaticallyCuratedSymbols
}

private func addOverloadGroupReferences(overloadGroups: [String: [String]]) {
private func addOverloadGroupReferences(overloadGroups: [String: Set<String>]) {
guard FeatureFlags.current.isExperimentalOverloadedSymbolPresentationEnabled else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ struct PathHierarchy {
existingNode.languages.insert(language!) // If we have symbols in this graph we have a language as well
} else {
assert(!symbol.pathComponents.isEmpty, "A symbol should have at least its own name in its path components.")

if symbol.identifier.precise.hasSuffix(SymbolGraph.Symbol.overloadGroupIdentifierSuffix),
loader.unifiedGraphs[moduleNode.name]?.symbols.keys.contains(symbol.identifier.precise) != true {
// Overload groups can be discarded in the unified symbol graph collector if
// they don't reflect the default overload across all platforms. In this
// case, we don't want to add these nodes to the path hierarchy since
// they've been discarded from the unified graph that's used to generate
// documentation nodes.
continue
}

let node = Node(symbol: symbol, name: symbol.pathComponents.last!)
// Disfavor synthesized symbols when they collide with other symbol with the same path.
// FIXME: Get information about synthesized symbols from SymbolKit https://github.com/apple/swift-docc-symbolkit/issues/58
Expand Down
11 changes: 3 additions & 8 deletions Sources/SwiftDocC/Model/DocumentationNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,9 @@ public struct DocumentationNode {
}

let overloadVariants = DocumentationDataVariants(
symbolData: unifiedSymbol.mixins,
platformName: platformName
) { mixins -> Symbol.Overloads? in
guard let overloadData = mixins[SymbolGraph.Symbol.OverloadData.mixinKey] as? SymbolGraph.Symbol.OverloadData else {
return nil
}
return .init(references: [], displayIndex: overloadData.overloadGroupIndex)
}
swiftVariant: unifiedSymbol.unifiedOverloadData.map { overloadData in
Symbol.Overloads(references: [], displayIndex: overloadData.overloadGroupIndex)
})

var languages = Set([reference.sourceLanguage])
var operatingSystemName = platformName.map({ Set([$0]) }) ?? []
Expand Down
9 changes: 7 additions & 2 deletions Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ import XCTest
import SymbolKit

extension XCTestCase {
public func makeSymbolGraph(moduleName: String, symbols: [SymbolGraph.Symbol] = [], relationships: [SymbolGraph.Relationship] = []) -> SymbolGraph {
public func makeSymbolGraph(
moduleName: String,
platform: SymbolGraph.Platform = .init(),
symbols: [SymbolGraph.Symbol] = [],
relationships: [SymbolGraph.Relationship] = []
) -> SymbolGraph {
return SymbolGraph(
metadata: SymbolGraph.Metadata(
formatVersion: SymbolGraph.SemanticVersion(major: 0, minor: 6, patch: 0),
generator: "unit-test"
),
module: SymbolGraph.Module(
name: moduleName,
platform: SymbolGraph.Platform(architecture: nil, vendor: nil, operatingSystem: nil)
platform: platform
),
symbols: symbols,
relationships: relationships
Expand Down
Loading