From c375a605fd1f7f0eeca215202cd8f8b5e357b5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20St=C3=BChrk?= Date: Mon, 26 Apr 2021 20:01:00 +0200 Subject: [PATCH 1/3] Fix the visibility of operator implementations. --- Sources/swift-doc/Subcommands/Generate.swift | 2 +- Sources/swift-doc/Supporting Types/Pages/OperatorPage.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/swift-doc/Subcommands/Generate.swift b/Sources/swift-doc/Subcommands/Generate.swift index 3aa48e88..2c04658d 100644 --- a/Sources/swift-doc/Subcommands/Generate.swift +++ b/Sources/swift-doc/Subcommands/Generate.swift @@ -76,7 +76,7 @@ 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) + pages[route(for: symbol)] = OperatorPage(module: module, symbol: symbol, baseURL: baseURL, includingImplementations: symbolFilter) 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 } From 2423dc9f90396111221252b17589436396e3157c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20St=C3=BChrk?= Date: Mon, 26 Apr 2021 20:13:04 +0200 Subject: [PATCH 2/3] Only include operators if they have at least one visible implementation. --- Sources/swift-doc/Subcommands/Generate.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/swift-doc/Subcommands/Generate.swift b/Sources/swift-doc/Subcommands/Generate.swift index 2c04658d..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, includingImplementations: symbolFilter) + 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: From 17d5cc9a45a56d1149db12639028a893cf25310e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20St=C3=BChrk?= Date: Wed, 28 Apr 2021 19:38:13 +0200 Subject: [PATCH 3/3] Add changelog for #264. --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) 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.