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

Commit b294240

Browse files
committed
Update layout and style
1 parent e1b8d78 commit b294240

16 files changed

+1428
-1369
lines changed

Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let package = Package(
1010
.package(url: "https://github.com/SwiftDocOrg/SwiftSemantics.git", .branch("swift-5.2")),
1111
.package(url: "https://github.com/SwiftDocOrg/CommonMark.git", .branch("master")),
1212
.package(url: "https://github.com/SwiftDocOrg/SwiftMarkup.git", .upToNextMinor(from: "0.0.5")),
13-
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", .revision("ce0327a62c4b5a5ddd4741406ea54f164f228a54")),
13+
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", .revision("03405c13dc1c31f50c08bbec6e7587cbee1c7fb3")),
1414
.package(url: "https://github.com/NSHipster/HypertextLiteral.git", .upToNextMinor(from: "0.0.2")),
1515
.package(url: "https://github.com/SwiftDocOrg/Markup.git", .revision("bcc9bff98749f8ed92221375591a1afd61b02f1a")),
1616
.package(url: "https://github.com/NSHipster/SwiftSyntaxHighlighter.git", .revision("fe39b4ec07e1e37872adf4b506d223ab27cf8cea")),

Sources/SwiftDoc/Interface.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public final class Interface: Codable {
1717
return Dictionary(grouping: symbols, by: { $0.id })
1818
}()
1919

20-
public lazy var symbolsGroupedByName: [String: [Symbol]] = {
21-
return Dictionary(grouping: symbols, by: { $0.name })
20+
public lazy var symbolsGroupedByQualifiedName: [String: [Symbol]] = {
21+
return Dictionary(grouping: symbols, by: { $0.id.description })
2222
}()
2323

2424
public private(set) lazy var topLevelSymbols: [Symbol] = {
@@ -101,10 +101,10 @@ public final class Interface: Codable {
101101
inheritedTypeNames = Set(inheritedTypeNames.flatMap { $0.split(separator: "&").map { $0.trimmingCharacters(in: .whitespaces) } })
102102

103103
for name in inheritedTypeNames {
104-
let inheritedTypes = symbols.filter({ ($0.api is Class || $0.api is Protocol) && $0.id.matches(name) })
104+
let inheritedTypes = symbols.filter({ ($0.api is Class || $0.api is Protocol) && $0.id.description == name })
105105
if inheritedTypes.isEmpty {
106106
let inherited = Symbol(api: Unknown(name: name), context: [], declaration: nil, documentation: nil, sourceLocation: nil)
107-
relationships.insert(Relationship(subject: symbol, predicate: .inheritsFrom, object: inherited))
107+
relationships.insert(Relationship(subject: symbol, predicate: .conformsTo, object: inherited))
108108
} else {
109109
for inherited in inheritedTypes {
110110
let predicate: Relationship.Predicate

Sources/SwiftDoc/Symbol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public final class Symbol {
4343
return true
4444
}
4545

46-
if let symbol = context.compactMap({ $0 as? Symbol }).first,
46+
if let symbol = context.compactMap({ $0 as? Symbol }).last,
4747
symbol.api.modifiers.contains(where: { $0.name == "public" })
4848
{
4949
switch symbol.api {

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@ extension Symbol {
88
var node: Node {
99
var node = Node(id.description)
1010
node.fontName = "Menlo"
11+
node.shape = .box
12+
node.style = .rounded
13+
14+
node.width = 3
15+
node.height = 0.5
16+
node.fixedSize = .shape
1117

1218
if !(api is Unknown) {
1319
node.href = "/" + path(for: self)
1420
}
1521

1622
switch api {
1723
case let `class` as Class:
18-
node.shape = .ellipse
24+
node.class = "class"
1925
if `class`.modifiers.contains(where: { $0.name == "final" }) {
2026
node.strokeWidth = 2.0
2127
}
28+
case is Enumeration:
29+
node.class = "enumeration"
2230
case is Structure:
23-
node.shape = .box
24-
node.style = .rounded
31+
node.class = "structure"
2532
case is Protocol:
26-
node.shape = .ellipse
27-
node.style = .dashed
33+
node.class = "protocol"
34+
case is Unknown:
35+
node.class = "unknown"
2836
default:
2937
break
3038
}
@@ -42,6 +50,7 @@ extension Symbol {
4250

4351
var symbolNode = self.node
4452
symbolNode.strokeWidth = 3.0
53+
symbolNode.class = [symbolNode.class, "current"].compactMap { $0 }.joined(separator: " ")
4554

4655
graph.append(symbolNode)
4756

@@ -64,12 +73,8 @@ extension Relationship {
6473
let to = object.node
6574

6675
var edge = Edge(from: from.id, to: to.id)
67-
switch predicate {
68-
case .conformsTo:
69-
edge.style = .dashed
70-
default:
71-
break
72-
}
76+
edge.class = predicate.rawValue
77+
edge.preferredEdgeLength = 1.5
7378

7479
return edge
7580
}

0 commit comments

Comments
 (0)