Skip to content

Commit aade6f9

Browse files
authored
Add missing links for nodes in relationship graph (swiftlang#153)
1 parent f83e898 commit aade6f9

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Sources/swift-doc/Extensions/SwiftDoc+Extensions.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,28 @@ extension Symbol {
3939
func graph(in module: Module, baseURL: String) -> Graph {
4040
var graph = Graph(directed: true)
4141

42-
let relationships = module.interface.relationships.filter {
43-
($0.predicate == .inheritsFrom || $0.predicate == .conformsTo) &&
44-
($0.subject == self || $0.object == self)
45-
}
42+
do {
43+
var node = self.node
4644

47-
var symbolNode = self.node
45+
if !(api is Unknown) {
46+
node.href = path(for: self, with: baseURL)
47+
}
4848

49-
if !(api is Unknown) {
50-
symbolNode.href = path(for: self, with: baseURL)
51-
}
49+
node.strokeWidth = 3.0
50+
node.class = [node.class, "current"].compactMap { $0 }.joined(separator: " ")
5251

53-
symbolNode.strokeWidth = 3.0
54-
symbolNode.class = [symbolNode.class, "current"].compactMap { $0 }.joined(separator: " ")
52+
graph.append(node)
53+
}
5554

56-
graph.append(symbolNode)
55+
let relationships = module.interface.relationships.filter {
56+
($0.predicate == .inheritsFrom || $0.predicate == .conformsTo) &&
57+
($0.subject == self || $0.object == self)
58+
}
5759

58-
for node in Set(relationships.flatMap { [$0.subject.node, $0.object.node] }) where node.id != symbolNode.id {
60+
for symbol in Set(relationships.flatMap { [$0.subject, $0.object] }) {
61+
guard self != symbol else { continue }
62+
var node = symbol.node
63+
node.href = path(for: symbol, with: baseURL)
5964
graph.append(node)
6065
}
6166

0 commit comments

Comments
 (0)