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

Fix operator implementation visibility #264

Merged
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed bug that caused operator implementations to appear in the documentation
although they should be omitted because of their lower access level.
#264 by @Lukas-Stuehrk
- Fixed bug that caused prefix and postfix operators to be omitted
from generated documentation.
#262 by @Lukas-Stuehrk.
Expand Down
5 changes: 4 additions & 1 deletion Sources/swift-doc/Subcommands/Generate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ extension SwiftDoc {
case let `typealias` as Typealias:
pages[route(for: `typealias`.name)] = TypealiasPage(module: module, symbol: symbol, baseURL: baseURL)
case is Operator:
pages[route(for: symbol)] = OperatorPage(module: module, symbol: symbol, baseURL: baseURL)
let operatorPage = OperatorPage(module: module, symbol: symbol, baseURL: baseURL, includingImplementations: symbolFilter)
if !operatorPage.implementations.isEmpty {
pages[route(for: symbol)] = operatorPage
}
case let function as Function where !function.isOperator:
globals[function.name, default: []] += [symbol]
case let variable as Variable:
Expand Down
4 changes: 2 additions & 2 deletions Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ struct OperatorPage: Page {
let implementations: [Symbol]
let baseURL: String

init(module: Module, symbol: Symbol, baseURL: String) {
init(module: Module, symbol: Symbol, baseURL: String, includingImplementations symbolFilter: (Symbol) -> Bool) {
precondition(symbol.api is Operator)
self.module = module
self.symbol = symbol
self.implementations = module.interface.functionsByOperator[symbol]?.sorted() ?? []
self.implementations = module.interface.functionsByOperator[symbol]?.filter(symbolFilter).sorted() ?? []
self.baseURL = baseURL
}

Expand Down