From 19aa0e453b9db2d31c752e652420ee12773412a2 Mon Sep 17 00:00:00 2001 From: ApolloZhu Date: Wed, 20 May 2020 04:26:46 -0400 Subject: [PATCH 1/3] Generate only for public symbols --- Sources/swift-doc/Supporting Types/Components/Members.swift | 4 +++- .../swift-doc/Supporting Types/Components/Relationships.swift | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/swift-doc/Supporting Types/Components/Members.swift b/Sources/swift-doc/Supporting Types/Components/Members.swift index d1af9950..d7d26a32 100644 --- a/Sources/swift-doc/Supporting Types/Components/Members.swift +++ b/Sources/swift-doc/Supporting Types/Components/Members.swift @@ -23,7 +23,9 @@ struct Members: Component { self.module = module self.baseURL = baseURL - self.members = module.interface.members(of: symbol).filter { $0.extension?.genericRequirements.isEmpty != false } + self.members = module.interface.members(of: symbol) + .filter { $0.extension?.genericRequirements.isEmpty != false } + .filter { $0.isPublic } self.typealiases = members.filter { $0.api is Typealias } self.initializers = members.filter { $0.api is Initializer } diff --git a/Sources/swift-doc/Supporting Types/Components/Relationships.swift b/Sources/swift-doc/Supporting Types/Components/Relationships.swift index 96e59a76..8febf849 100644 --- a/Sources/swift-doc/Supporting Types/Components/Relationships.swift +++ b/Sources/swift-doc/Supporting Types/Components/Relationships.swift @@ -64,7 +64,7 @@ struct Relationships: Component { ("Subclasses", module.interface.typesInheriting(from: symbol)), ("Conforms To", module.interface.typesConformed(by: symbol)), ("Types Conforming to \(softbreak(symbol.id.description))", module.interface.typesConforming(to: symbol)), - ].filter { !$0.symbols.isEmpty } + ].map { (title: $0.0, symbols: $0.1.filter { $0.isPublic }) }.filter { !$0.symbols.isEmpty } } // MARK: - Component From c86d691fa794c331f26c45643be1cb420879a849 Mon Sep 17 00:00:00 2001 From: ApolloZhu Date: Wed, 20 May 2020 04:59:04 -0400 Subject: [PATCH 2/3] Get extension from property --- Sources/SwiftDoc/Symbol.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftDoc/Symbol.swift b/Sources/SwiftDoc/Symbol.swift index c41f5933..c79f86f7 100644 --- a/Sources/SwiftDoc/Symbol.swift +++ b/Sources/SwiftDoc/Symbol.swift @@ -37,9 +37,8 @@ public final class Symbol { return true } - if let `extension` = context.compactMap({ $0 as? Extension }).first, - `extension`.modifiers.contains(where: { $0.name == "public" }) - { + if let `extension` = `extension`, + `extension`.modifiers.contains(where: { $0.name == "public" }) { return true } From 1ded880a714d22fade634546e16c7c33bade63ba Mon Sep 17 00:00:00 2001 From: ApolloZhu Date: Wed, 20 May 2020 05:00:50 -0400 Subject: [PATCH 3/3] Assume unkown is public If you can access it from not where it's defined, it should be public. This fixes protocol conformances not showing up. --- Sources/SwiftDoc/Symbol.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/SwiftDoc/Symbol.swift b/Sources/SwiftDoc/Symbol.swift index c79f86f7..02514f8e 100644 --- a/Sources/SwiftDoc/Symbol.swift +++ b/Sources/SwiftDoc/Symbol.swift @@ -33,6 +33,10 @@ public final class Symbol { }() public var isPublic: Bool { + if api is Unknown { + return true + } + if api.modifiers.contains(where: { $0.name == "public" || $0.name == "open" }) { return true }