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

Commit 4ec92a5

Browse files
Fix operator implementation visibility (#264)
* Fix the visibility of operator implementations. * Only include operators if they have at least one visible implementation. * Add changelog for #264.
1 parent cc45688 commit 4ec92a5

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

20+
- Fixed bug that caused operator implementations to appear in the documentation
21+
although they should be omitted because of their lower access level.
22+
#264 by @Lukas-Stuehrk
2023
- Fixed bug that caused prefix and postfix operators to be omitted
2124
from generated documentation.
2225
#262 by @Lukas-Stuehrk.

Sources/swift-doc/Subcommands/Generate.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ extension SwiftDoc {
7676
case let `typealias` as Typealias:
7777
pages[route(for: `typealias`.name)] = TypealiasPage(module: module, symbol: symbol, baseURL: baseURL)
7878
case is Operator:
79-
pages[route(for: symbol)] = OperatorPage(module: module, symbol: symbol, baseURL: baseURL)
79+
let operatorPage = OperatorPage(module: module, symbol: symbol, baseURL: baseURL, includingImplementations: symbolFilter)
80+
if !operatorPage.implementations.isEmpty {
81+
pages[route(for: symbol)] = operatorPage
82+
}
8083
case let function as Function where !function.isOperator:
8184
globals[function.name, default: []] += [symbol]
8285
case let variable as Variable:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ struct OperatorPage: Page {
99
let implementations: [Symbol]
1010
let baseURL: String
1111

12-
init(module: Module, symbol: Symbol, baseURL: String) {
12+
init(module: Module, symbol: Symbol, baseURL: String, includingImplementations symbolFilter: (Symbol) -> Bool) {
1313
precondition(symbol.api is Operator)
1414
self.module = module
1515
self.symbol = symbol
16-
self.implementations = module.interface.functionsByOperator[symbol]?.sorted() ?? []
16+
self.implementations = module.interface.functionsByOperator[symbol]?.filter(symbolFilter).sorted() ?? []
1717
self.baseURL = baseURL
1818
}
1919

0 commit comments

Comments
 (0)