8000 Add missing links for nodes in relationship graph by mattt · Pull Request #153 · SwiftDocOrg/swift-doc · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Add missing links for nodes in relationship graph #153

Merged
merged 2 commits into from
Jul 31, 2020
Merged
Changes from 1 commit
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
Next Next commit
Add missing links for nodes in relationship graph
  • Loading branch information
mattt committed Jul 31, 2020
commit 3ef1e893d83a544804a4a16ce35200c8492f46a0
29 changes: 17 additions & 12 deletions Sources/swift-doc/Extensions/SwiftDoc+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,28 @@ extension Symbol {
func graph(in module: Module, baseURL: String) -> Graph {
var graph = Graph(directed: true)

let relationships = module.interface.relationships.filter {
($0.predicate == .inheritsFrom || $0.predicate == .conformsTo) &&
($0.subject == self || $0.object == self)
}
do {
var node = self.node

var symbolNode = self.node
if !(api is Unknown) {
node.href = path(for: self, with: baseURL)
}

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

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

graph.append(symbolNode)
let relationships = module.interface.relationships.filter {
($0.predicate == .inheritsFrom || $0.predicate == .conformsTo) &&
($0.subject == self || $0.object == self)
}

for node in Set(relationships.flatMap { [$0.subject.node, $0.object.node] }) where node.id != symbolNode.id {
for symbol in Set(relationships.flatMap { [$0.subject, $0.object] }) {
guard self != symbol else { continue }
var node = symbol.node
node.href = path(for: symbol, with: baseURL)
graph.append(node)
}

Expand Down
0