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

Commit 4982b02

Browse files
committed
Don't link to not included symbols in the Relationships section.
1 parent 467cf38 commit 4982b02

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ extension Symbol {
3636
return node
3737
}
3838

39-
func graph(in module: Module, baseURL: String) -> Graph {
39+
func graph(in module: Module, baseURL: String, symbolFilter: (Symbol) -> Bool) -> Graph {
4040
var graph = Graph(directed: true)
4141

4242
do {
4343
var node = self.node
4444

45-
if !(api is Unknown) {
45+
if !(api is Unknown) && symbolFilter(self) {
4646
node.href = path(for: self, with: baseURL)
4747
}
4848

@@ -61,7 +61,7 @@ extension Symbol {
6161
guard self != symbol else { continue }
6262
var node = symbol.node
6363

64-
if !(symbol.api is Unknown) {
64+
if !(symbol.api is Unknown) && symbolFilter(symbol) {
6565
node.href = path(for: symbol, with: baseURL)
6666
}
6767
graph.append(node)

Sources/swift-doc/Supporting Types/Components/Relationships.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ struct Relationships: Component {
3030
var symbol: Symbol
3131
let baseURL: String
3232
var inheritedTypes: [Symbol]
33+
let symbolFilter: (Symbol) -> Bool
3334

34-
init(of symbol: Symbol, in module: Module, baseURL: String) {
35+
init(of symbol: Symbol, in module: Module, baseURL: String, symbolFilter: @escaping (Symbol) -> Bool) {
3536
self.module = module
3637
self.symbol = symbol
3738
self.inheritedTypes = module.interface.typesInherited(by: symbol) + module.interface.typesConformed(by: symbol)
3839
self.baseURL = baseURL
40+
self.symbolFilter = symbolFilter
3941
}
4042

4143
var graphHTML: HypertextLiteral.HTML? {
42-
var graph = symbol.graph(in: module, baseURL: baseURL)
44+
var graph = symbol.graph(in: module, baseURL: baseURL, symbolFilter: symbolFilter)
4345
guard !graph.edges.isEmpty else { return nil }
4446

4547
graph.aspectRatio = 0.125

Sources/swift-doc/Supporting Types/Pages/TypePage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct TypePage: Page {
2828
Heading { symbol.id.description }
2929

3030
Documentation(for: symbol, in: module, baseURL: baseURL)
31-
Relationships(of: symbol, in: module, baseURL: baseURL)
31+
Relationships(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter)
3232
Members(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter)
3333
Requirements(of: symbol, in: module, baseURL: baseURL)
3434
}
@@ -42,7 +42,7 @@ struct TypePage: Page {
4242
</h1>
4343
4444
\#(Documentation(for: symbol, in: module, baseURL: baseURL).html)
45-
\#(Relationships(of: symbol, in: module, baseURL: baseURL).html)
45+
\#(Relationships(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter).html)
4646
\#(Members(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter).html)
4747
\#(Requirements(of: symbol, in: module, baseURL: baseURL).html)
4848
"""#

0 commit comments

Comments
 (0)