Skip to content

Commit 7eae6e7

Browse files
authored
Merge pull request #1983 from cmcgee1024/add_symbol_graph_skip_inherited_docs
Add symbol graph options for skipping inherited docs
2 parents a0d7658 + 1bc5d3a commit 7eae6e7

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ extension Driver {
909909
try commandLine.appendLast(.symbolGraphMinimumAccessLevel, from: &parsedOptions)
910910
try commandLine.appendLast(.symbolGraphPrettyPrint, from: &parsedOptions)
911911
try commandLine.appendLast(.symbolGraphSkipSynthesizedMembers, from: &parsedOptions)
912+
try commandLine.appendLast(.symbolGraphSkipInheritedDocs, from: &parsedOptions)
912913
}
913914

914915
mutating func addEntry(_ entries: inout [VirtualPath.Handle: [FileType: VirtualPath.Handle]], input: TypedVirtualPath?, output: TypedVirtualPath) throws {

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ extension Option {
891891
public static let symbolGraphBlockAvailabilityPlatforms: Option = Option("-symbol-graph-block-availability-platforms", .separate, attributes: [.helpHidden, .frontend, .noInteractive, .supplementaryOutput], metaVar: "<platforms>", helpText: "Remove the given platforms from symbol graph availability metadata, e.g. 'macOS,Swift'")
892892
public static let symbolGraphPrettyPrint: Option = Option("-symbol-graph-pretty-print", .flag, attributes: [.helpHidden, .noInteractive], helpText: "Pretty-print the output symbol graph JSON")
893893
public static let symbolGraphSkipSynthesizedMembers: Option = Option("-symbol-graph-skip-synthesized-members", .flag, attributes: [.helpHidden, .noInteractive], helpText: "Skip members inherited through classes or default implementations")
894+
public static let symbolGraphSkipInheritedDocs: Option = Option("-symbol-graph-skip-inherited-docs", .flag, attributes: [.helpHidden, .noInteractive], helpText: "Skip emitting doc comments for members inherited through classes or default implementations")
894895
public static let symbolGraphMinimumAccessLevel: Option = Option("-symbol-graph-minimum-access-level", .separate, attributes: [.helpHidden, .frontend, .noInteractive, .supplementaryOutput], metaVar: "<level>", helpText: "Include symbols with this access level or more when emitting a symbol graph")
895896
public static let sysroot: Option = Option("-sysroot", .separate, attributes: [.frontend, .synthesizeInterface, .argumentIsPath], metaVar: "<sysroot>", helpText: "Native Platform sysroot")
896897
public static let S: Option = Option("-S", .flag, alias: Option.emitAssembly, attributes: [.frontend, .noInteractive], group: .modes)
@@ -1864,6 +1865,7 @@ extension Option {
18641865
Option.symbolGraphMinimumAccessLevel,
18651866
Option.symbolGraphPrettyPrint,
18661867
Option.symbolGraphSkipSynthesizedMembers,
1868+
Option.symbolGraphSkipInheritedDocs,
18671869
Option.sysroot,
18681870
Option.S,
18691871
Option.tabWidth,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,6 +3576,19 @@ final class SwiftDriverTests: XCTestCase {
35763576
}
35773577
}
35783578

3579+
func testEmitSymbolGraphSkipInheritedDocs() throws {
3580+
do {
3581+
let root = localFileSystem.currentWorkingDirectory!.appending(components: "foo", "bar")
3582+
3583+
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.swift", "-module-name", "Test", "-emit-module-path", rebase("Test.swiftmodule", at: root), "-emit-symbol-graph", "-emit-symbol-graph-dir", "/foo/bar/", "-symbol-graph-skip-inherited-docs", "-emit-library"])
3584+
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
3585+
3586+
// We don't know the output file of the symbol graph, just make sure the flag is passed along.
3587+
XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-emit-symbol-graph"))
3588+
XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-symbol-graph-skip-inherited-docs"))
3589+
}
3590+
}
3591+
35793592
func testEmitModuleSeparately() throws {
35803593
var envVars = ProcessEnv.block
35813594
envVars["SWIFT_DRIVER_LD_EXEC"] = ld.nativePathString(escaped: false)

0 commit comments

Comments
 (0)