diff --git a/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift b/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift index 193722b..d4af11e 100644 --- a/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift +++ b/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift @@ -16,7 +16,8 @@ extension UnifiedSymbolGraph: Encodable { case moduleData case metadata case symbols - case relationships + case relationshipsByLanguage + case orphanRelationships } private struct EncodableModuleData: Encodable { @@ -29,6 +30,11 @@ extension UnifiedSymbolGraph: Encodable { var metadata: SymbolGraph.Metadata } + private struct EncodableRelationships: Encodable { + var selector: Selector + var relationships: [SymbolGraph.Relationship] + } + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) @@ -41,6 +47,10 @@ extension UnifiedSymbolGraph: Encodable { try container.encode(encodableMetadata, forKey: .metadata) try container.encode(Array(symbols.values), forKey: .symbols) - try container.encode(relationships, forKey: .relationships) + + let encodableRelationships = relationshipsByLanguage.map({ EncodableRelationships(selector: $0.key, relationships: $0.value) }) + try container.encode(encodableRelationships, forKey: .relationshipsByLanguage) + + try container.encode(orphanRelationships, forKey: .orphanRelationships) } } diff --git a/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph.swift b/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph.swift index 50c58de..19e1213 100644 --- a/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph.swift +++ b/Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph.swift @@ -28,7 +28,7 @@ public class UnifiedSymbolGraph { public var symbols: [String: UnifiedSymbolGraph.Symbol] /// The relationships between symbols. - @available(*, deprecated, message: "Use unifiedRelationships and orphanRelationships instead") + @available(*, deprecated, message: "Use relationshipsByLanguage and orphanRelationships instead") public var relationships: [SymbolGraph.Relationship] { var allRelations = mergeRelationships(Array(relationshipsByLanguage.values.joined())) allRelations.append(contentsOf: self.orphanRelationships)