@@ -19,6 +19,7 @@ import PackageGraph
19
19
import PackageModel
20
20
import SourceControl
21
21
import Workspace
22
+ import ArgumentParser
22
23
23
24
/// A wrapper for swift-symbolgraph-extract tool.
24
25
public struct SymbolGraphExtract {
@@ -29,7 +30,12 @@ public struct SymbolGraphExtract {
29
30
}
30
31
31
32
public func dumpSymbolGraph(
32
- buildPlan: BuildPlan
33
+ buildPlan: BuildPlan ,
34
+ prettyPrint: Bool ,
35
+ skipSynthesisedMembers: Bool ,
36
+ minimumAccessLevel: AccessLevel ,
37
+ skipInheritedDocs: Bool ,
38
+ includeSpiSymbols: Bool
33
39
) throws {
34
40
let buildParameters = buildPlan. buildParameters
35
41
let symbolGraphDirectory = buildPlan. buildParameters. symbolGraph
@@ -47,6 +53,14 @@ public struct SymbolGraphExtract {
47
53
48
54
args += [ " -output-dir " , symbolGraphDirectory. pathString]
49
55
56
+ if prettyPrint { args. append ( " -pretty-print " ) }
57
+ if skipSynthesisedMembers { args. append ( " -skip-synthesized-members " ) }
58
+ if minimumAccessLevel != SwiftPackageTool . DumpSymbolGraph. defaultMinimumAccessLevel {
59
+ args += [ " -minimum-access-level " , minimumAccessLevel. rawValue]
60
+ }
61
+ if skipInheritedDocs { args. append ( " -skip-inherited-docs " ) }
62
+ if includeSpiSymbols { args. append ( " -include-spi-symbols " ) }
63
+
50
64
print ( " -- Emitting symbol graph for " , target. name)
51
65
try runTool ( args)
52
66
}
@@ -65,6 +79,16 @@ public struct SymbolGraphExtract {
65
79
}
66
80
}
67
81
82
+ /// Access control levels.
83
+ public enum AccessLevel : String , RawRepresentable , CustomStringConvertible , CaseIterable {
84
+ // The cases reflect those found in `include/swift/AST/AttrKind.h` of the swift compiler (at commit 03f55d7bb4204ca54841218eb7cc175ae798e3bd)
85
+ case `private`, `fileprivate`, `internal`, `public`, `open`
86
+
87
+ public var description : String { rawValue }
88
+ }
89
+
90
+ extension AccessLevel : ExpressibleByArgument { }
91
+
68
92
extension BuildParameters {
69
93
/// The directory containing artifacts generated by the symbolgraph-extract tool.
70
94
var symbolGraph : AbsolutePath {
0 commit comments