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

Commit ed4a680

Browse files
ApolloZhumattt
andauthored
Generate docs only for public symbols (#116)
* Generate only for public symbols * Get extension from property * 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. Co-authored-by: Mattt <mattt@me.com>
1 parent 8b1a8a1 commit ed4a680

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Sources/SwiftDoc/Symbol.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ public final class Symbol {
3333
}()
3434

3535
public var isPublic: Bool {
36+
if api is Unknown {
37+
return true
38+
}
39+
3640
if api.modifiers.contains(where: { $0.name == "public" || $0.name == "open" }) {
3741
return true
3842
}
3943

40-
if let `extension` = context.compactMap({ $0 as? Extension }).first,
41-
`extension`.modifiers.contains(where: { $0.name == "public" })
42-
{
44+
if let `extension` = `extension`,
45+
`extension`.modifiers.contains(where: { $0.name == "public" }) {
4346
return true
4447
}
4548

Sources/swift-doc/Supporting Types/Components/Members.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ struct Members: Component {
2323
self.module = module
2424
self.baseURL = baseURL
2525

26-
self.members = module.interface.members(of: symbol).filter { $0.extension?.genericRequirements.isEmpty != false }
26+
self.members = module.interface.members(of: symbol)
27+
.filter { $0.extension?.genericRequirements.isEmpty != false }
28+
.filter { $0.isPublic }
2729

2830
self.typealiases = members.filter { $0.api is Typealias }
2931
self.initializers = members.filter { $0.api is Initializer }

Sources/swift-doc/Supporting Types/Components/Relationships.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct Relationships: Component {
6464
("Subclasses", module.interface.typesInheriting(from: symbol)),
6565
("Conforms To", module.interface.typesConformed(by: symbol)),
6666
("Types Conforming to <code>\(softbreak(symbol.id.description))</code>", module.interface.typesConforming(to: symbol)),
67-
].filter { !$0.symbols.isEmpty }
67+
].map { (title: $0.0, symbols: $0.1.filter { $0.isPublic }) }.filter { !$0.symbols.isEmpty }
6868
}
6969

7070
// MARK: - Component

0 commit comments

Comments
 (0)