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

Don't link to not included symbols in the Relationships section. #226

Merged
merged 4 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed public extensions exposing nested code of all access levels.
#195 by @Tunous.
- Fixed broken links in the relationship graph.
#226 by @Lukas-Stuehrk.

### Changed

Expand Down
6 changes: 3 additions & 3 deletions Sources/swift-doc/Extensions/SwiftDoc+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ extension Symbol {
return node
}

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

do {
var node = self.node

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

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

if !(symbol.api is Unknown) {
if !(symbol.api is Unknown) && symbolFilter(symbol) {
node.href = path(for: symbol, with: baseURL)
}
graph.append(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ struct Relationships: Component {
var symbol: Symbol
let baseURL: String
var inheritedTypes: [Symbol]
let symbolFilter: (Symbol) -> Bool

init(of symbol: Symbol, in module: Module, baseURL: String) {
init(of symbol: Symbol, in module: Module, baseURL: String, includingChildren symbolFilter: @escaping (Symbol) -> Bool) {
self.module = module
self.symbol = symbol
self.inheritedTypes = module.interface.typesInherited(by: symbol) + module.interface.typesConformed(by: symbol)
self.baseURL = baseURL
self.symbolFilter = symbolFilter
}

var graphHTML: HypertextLiteral.HTML? {
var graph = symbol.graph(in: module, baseURL: baseURL)
var graph = symbol.graph(in: module, baseURL: baseURL, includingChildren: symbolFilter)
guard !graph.edges.isEmpty else { return nil }

graph.aspectRatio = 0.125
Expand Down
4 changes: 2 additions & 2 deletions Sources/swift-doc/Supporting Types/Pages/TypePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct TypePage: Page {
Heading { symbol.id.description }

Documentation(for: symbol, in: module, baseURL: baseURL)
Relationships(of: symbol, in: module, baseURL: baseURL)
Relationships(of: symbol, in: module, baseURL: baseURL, includingChildren: symbolFilter)
Members(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter)
Requirements(of: symbol, in: module, baseURL: baseURL)
}
Expand All @@ -42,7 +42,7 @@ struct TypePage: Page {
</h1>

\#(Documentation(for: symbol, in: module, baseURL: baseURL).html)
\#(Relationships(of: symbol, in: module, baseURL: baseURL).html)
\#(Relationships(of: symbol, in: module, baseURL: baseURL, includingChildren: symbolFilter).html)
\#(Members(of: symbol, in: module, baseURL: baseURL, symbolFilter: symbolFilter).html)
\#(Requirements(of: symbol, in: module, baseURL: baseURL).html)
"""#
Expand Down