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

Commit

Permalink
Fix operator implementation visibility (#264)
Browse files Browse the repository at this point in the history
* Fix the visibility of operator implementations.

* Only include operators if they have at least one visible implementation.

* Add changelog for #264.
  • Loading branch information
Lukas-Stuehrk authored May 18, 2021
1 parent cc45688 commit 4ec92a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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

0 comments on commit 4ec92a5

Please sign in to comment.