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

Generate docs only for public symbols #116

Merged
merged 4 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Sources/SwiftDoc/Symbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ 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
}

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
}

Expand Down
4 changes: 3 additions & 1 deletion Sources/swift-doc/Supporting Types/Components/Members.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct Relationships: Component {
("Subclasses", module.interface.typesInheriting(from: symbol)),
("Conforms To", module.interface.typesConformed(by: symbol)),
("Types Conforming to <code>\(softbreak(symbol.id.description))</code>", 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
Expand Down