diff --git a/Changelog.md b/Changelog.md index 538190ea..8fb6ef8f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/Sources/swift-doc/Subcommands/Generate.swift b/Sources/swift-doc/Subcommands/Generate.swift index 3aa48e88..76802c54 100644 --- a/Sources/swift-doc/Subcommands/Generate.swift +++ b/Sources/swift-doc/Subcommands/Generate.swift @@ -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: diff --git a/Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift b/Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift index d8a428a2..740e7829 100644 --- a/Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift +++ b/Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift @@ -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 }