Skip to content

Commit 978b179

Browse files
cmcgee1024Chris McGeeowenv
authored
Add DocC skip inherited docs parameter as a build setting (#794)
* Add DocC skip inherited docs parameter as a build setting --------- Co-authored-by: Chris McGee <[email protected]> Co-authored-by: Owen Voorhees <[email protected]>
1 parent ad1c3cf commit 978b179

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ public final class BuiltinMacros {
11001100
public static let DOCC_PRETTY_PRINT = BuiltinMacros.declareBooleanMacro("DOCC_PRETTY_PRINT")
11011101
public static let DOCC_EXTRACT_SPI_DOCUMENTATION = BuiltinMacros.declareBooleanMacro("DOCC_EXTRACT_SPI_DOCUMENTATION")
11021102
public static let DOCC_MINIMUM_ACCESS_LEVEL = BuiltinMacros.declareEnumMacro("DOCC_MINIMUM_ACCESS_LEVEL") as EnumMacroDeclaration<DoccMinimumAccessLevel>
1103+
public static let DOCC_SKIP_INHERITED_DOCS = BuiltinMacros.declareBooleanMacro("DOCC_SKIP_INHERITED_DOCS")
11031104
public static let DOCC_SKIP_SYNTHESIZED_MEMBERS = BuiltinMacros.declareBooleanMacro("DOCC_SKIP_SYNTHESIZED_MEMBERS")
11041105
public static let DOCC_EXTRACT_EXTENSION_SYMBOLS = BuiltinMacros.declareBooleanMacro("DOCC_EXTRACT_EXTENSION_SYMBOLS")
11051106
public static let DOCC_EXTRACT_SWIFT_INFO_FOR_OBJC_SYMBOLS = BuiltinMacros.declareBooleanMacro("DOCC_EXTRACT_SWIFT_INFO_FOR_OBJC_SYMBOLS")
@@ -1651,6 +1652,7 @@ public final class BuiltinMacros {
16511652
DISABLE_XCFRAMEWORK_SIGNATURE_VALIDATION,
16521653
DOCC_ARCHIVE_PATH,
16531654
DOCC_PRETTY_PRINT,
1655+
DOCC_SKIP_INHERITED_DOCS,
16541656
DOCC_SKIP_SYNTHESIZED_MEMBERS,
16551657
DOCC_MINIMUM_ACCESS_LEVEL,
16561658
DOCC_EXTRACT_SPI_DOCUMENTATION,

Sources/SWBCore/SpecImplementations/Tools/DocumentationCompiler.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ final public class DocumentationCompilerSpec: GenericCompilerSpec, SpecIdentifie
9292
additionalFlags.append("-symbol-graph-skip-synthesized-members")
9393
}
9494

95+
// Check if inherited docs should be skipped
96+
if cbc.scope.evaluate(BuiltinMacros.DOCC_SKIP_INHERITED_DOCS) {
97+
additionalFlags.append("-symbol-graph-skip-inherited-docs")
98+
}
99+
95100
switch cbc.scope.evaluate(BuiltinMacros.DOCC_MINIMUM_ACCESS_LEVEL) {
96101
case .none:
97102
switch DocumentationType(from: cbc) {

Sources/SWBUniversalPlatform/Specs/Documentation.xcspec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@
168168
DefaultValue = NO;
169169
},
170170

171+
// If the swift compiler / Swift symbol graph extractor should skip inherited docs
172+
{
173+
Name = DOCC_SKIP_INHERITED_DOCS;
174+
Type = bool;
175+
DefaultValue = NO;
176+
},
177+
171178
// If the Swift compiler / Swift symbol graph extractor should skip synthesized members.
172179
{
173180
Name = DOCC_SKIP_SYNTHESIZED_MEMBERS;

Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ import SWBMacro
8181
swiftCompilerInfo: try mockSwiftCompilerSpec(swiftVersion: "5.6", swiftTag: "swiftlang-5.6.0.0")
8282
)
8383
#expect(skipSynthesizedMembers == ["-symbol-graph-skip-synthesized-members"])
84+
85+
let skipInheritedDocs = await DocumentationCompilerSpec.additionalSymbolGraphGenerationArgs(
86+
try mockApplicationBuildContext(application: false, skipInheritedDocs: true),
87+
swiftCompilerInfo: try mockSwiftCompilerSpec(swiftVersion: "5.6", swiftTag: "swiftlang-5.6.0.0")
88+
)
89+
#expect(skipInheritedDocs == ["-symbol-graph-skip-inherited-docs"])
8490
}
8591

86-
private func mockApplicationBuildContext(application: Bool, minimumAccessLevel: DoccMinimumAccessLevel = .none, prettyPrint: Bool = false, skipSynthesizedMembers: Bool = false) async throws -> CommandBuildContext {
92+
private func mockApplicationBuildContext(application: Bool, minimumAccessLevel: DoccMinimumAccessLevel = .none, prettyPrint: Bool = false, skipSynthesizedMembers: Bool = false, skipInheritedDocs: Bool = false) async throws -> CommandBuildContext {
8793
let core = try await getCore()
8894

8995
let producer = try MockCommandProducer(
@@ -107,6 +113,10 @@ import SWBMacro
107113
mockTable.push(BuiltinMacros.DOCC_SKIP_SYNTHESIZED_MEMBERS, literal: skipSynthesizedMembers)
108114
}
109115

116+
if skipInheritedDocs {
117+
mockTable.push(BuiltinMacros.DOCC_SKIP_INHERITED_DOCS, literal: true)
118+
}
119+
110120
let mockScope = MacroEvaluationScope(table: mockTable)
111121

112122
return CommandBuildContext(producer: producer, scope: mockScope, inputs: [])

0 commit comments

Comments
 (0)