Skip to content

Commit 9ebaf2b

Browse files
Add package access level to access level enums (#8261)
Currently the symbol graph generator defaults to "public" minimum access level even if the user tries to initialize the options with "package" this is because the internal enums representing access level don't have a notion of `package` access control. ### Motivation: Currently it is not possible to generate documentation only for `package` and `public` symbols. This changes that ### Modifications: Adds `package` values to enums representing access control along the symbol graph generation code path. ### Result: When invoking [swift-docc-plugin](https://github.com/apple/swift-docc-plugin) with `--symbol-graph-minimum-access-level package` the resulting documentation contains `public` and `package` access controlled symbols.
1 parent bdb59e8 commit 9ebaf2b

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

Sources/Commands/Utilities/PluginDelegate.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ final class PluginDelegate: PluginInvocationDelegate {
442442
symbolGraphExtractor.minimumAccessLevel = .fileprivate
443443
case .internal:
444444
symbolGraphExtractor.minimumAccessLevel = .internal
445+
case .package:
446+
symbolGraphExtractor.minimumAccessLevel = .package
445447
case .public:
446448
symbolGraphExtractor.minimumAccessLevel = .public
447449
case .open:

Sources/Commands/Utilities/SymbolGraphExtract.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ package struct SymbolGraphExtract {
4040

4141
/// Access control levels.
4242
public enum AccessLevel: String, RawRepresentable, CaseIterable, ExpressibleByArgument {
43-
// The cases reflect those found in `include/swift/AST/AttrKind.h` of the swift compiler (at commit 03f55d7bb4204ca54841218eb7cc175ae798e3bd)
44-
case `private`, `fileprivate`, `internal`, `public`, `open`
43+
// The cases reflect those found in `include/swift/AST/AttrKind.h` of the swift compiler (at commit ca96a2b)
44+
case `private`, `fileprivate`, `internal`, `package`, `public`, `open`
4545
}
4646

4747
/// Output format of the generated symbol graph.

Sources/PackagePlugin/PackageManagerProxy.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public struct PackageManager {
245245

246246
/// Represents a Swift access level.
247247
public enum AccessLevel: String, CaseIterable {
248-
case `private`, `fileprivate`, `internal`, `public`, open
248+
case `private`, `fileprivate`, `internal`, `package`, `public`, open
249249
}
250250

251251
/// Whether to include synthesized members.
@@ -472,6 +472,8 @@ extension PluginToHostMessage.SymbolGraphOptions.AccessLevel {
472472
self = .internal
473473
case .public:
474474
self = .public
475+
case .package:
476+
self = .package
475477
case .open:
476478
self = .open
477479
}

Sources/PackagePlugin/PluginMessages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ enum PluginToHostMessage: Codable {
331331
struct SymbolGraphOptions: Codable {
332332
var minimumAccessLevel: AccessLevel
333333
enum AccessLevel: String, Codable {
334-
case `private`, `fileprivate`, `internal`, `public`, `open`
334+
case `private`, `fileprivate`, `internal`, `package`, `public`, `open`
335335
}
336336
var includeSynthesized: Bool
337337
var includeSPI: Bool

Sources/SPMBuildCore/Plugins/PluginInvocation.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ final class DefaultPluginInvocationDelegate: PluginInvocationDelegate {
881881
public struct PluginInvocationSymbolGraphOptions {
882882
public var minimumAccessLevel: AccessLevel
883883
public enum AccessLevel: String {
884-
case `private`, `fileprivate`, `internal`, `public`, `open`
884+
case `private`, `fileprivate`, `internal`, `package`, `public`, `open`
885885
}
886886
public var includeSynthesized: Bool
887887
public var includeSPI: Bool
@@ -1163,6 +1163,8 @@ fileprivate extension PluginInvocationSymbolGraphOptions.AccessLevel {
11631163
self = .fileprivate
11641164
case .internal:
11651165
self = .internal
1166+
case .package:
1167+
self = .package
11661168
case .public:
11671169
self = .public
11681170
case .open:

0 commit comments

Comments
 (0)