diff --git a/Sources/SWBCore/Settings/BuiltinMacros.swift b/Sources/SWBCore/Settings/BuiltinMacros.swift index 7a9704a5..7570b70b 100644 --- a/Sources/SWBCore/Settings/BuiltinMacros.swift +++ b/Sources/SWBCore/Settings/BuiltinMacros.swift @@ -1100,6 +1100,7 @@ public final class BuiltinMacros { public static let DOCC_PRETTY_PRINT = BuiltinMacros.declareBooleanMacro("DOCC_PRETTY_PRINT") public static let DOCC_EXTRACT_SPI_DOCUMENTATION = BuiltinMacros.declareBooleanMacro("DOCC_EXTRACT_SPI_DOCUMENTATION") public static let DOCC_MINIMUM_ACCESS_LEVEL = BuiltinMacros.declareEnumMacro("DOCC_MINIMUM_ACCESS_LEVEL") as EnumMacroDeclaration + public static let DOCC_SKIP_INHERITED_DOCS = BuiltinMacros.declareBooleanMacro("DOCC_SKIP_INHERITED_DOCS") public static let DOCC_SKIP_SYNTHESIZED_MEMBERS = BuiltinMacros.declareBooleanMacro("DOCC_SKIP_SYNTHESIZED_MEMBERS") public static let DOCC_EXTRACT_EXTENSION_SYMBOLS = BuiltinMacros.declareBooleanMacro("DOCC_EXTRACT_EXTENSION_SYMBOLS") 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 { DISABLE_XCFRAMEWORK_SIGNATURE_VALIDATION, DOCC_ARCHIVE_PATH, DOCC_PRETTY_PRINT, + DOCC_SKIP_INHERITED_DOCS, DOCC_SKIP_SYNTHESIZED_MEMBERS, DOCC_MINIMUM_ACCESS_LEVEL, DOCC_EXTRACT_SPI_DOCUMENTATION, diff --git a/Sources/SWBCore/SpecImplementations/Tools/DocumentationCompiler.swift b/Sources/SWBCore/SpecImplementations/Tools/DocumentationCompiler.swift index b4b5e5ab..705dee00 100644 --- a/Sources/SWBCore/SpecImplementations/Tools/DocumentationCompiler.swift +++ b/Sources/SWBCore/SpecImplementations/Tools/DocumentationCompiler.swift @@ -92,6 +92,11 @@ final public class DocumentationCompilerSpec: GenericCompilerSpec, SpecIdentifie additionalFlags.append("-symbol-graph-skip-synthesized-members") } + // Check if inherited docs should be skipped + if cbc.scope.evaluate(BuiltinMacros.DOCC_SKIP_INHERITED_DOCS) { + additionalFlags.append("-symbol-graph-skip-inherited-docs") + } + switch cbc.scope.evaluate(BuiltinMacros.DOCC_MINIMUM_ACCESS_LEVEL) { case .none: switch DocumentationType(from: cbc) { diff --git a/Sources/SWBUniversalPlatform/Specs/Documentation.xcspec b/Sources/SWBUniversalPlatform/Specs/Documentation.xcspec index 6cafd5e3..3aca332d 100644 --- a/Sources/SWBUniversalPlatform/Specs/Documentation.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/Documentation.xcspec @@ -168,6 +168,13 @@ DefaultValue = NO; }, + // If the swift compiler / Swift symbol graph extractor should skip inherited docs + { + Name = DOCC_SKIP_INHERITED_DOCS; + Type = bool; + DefaultValue = NO; + }, + // If the Swift compiler / Swift symbol graph extractor should skip synthesized members. { Name = DOCC_SKIP_SYNTHESIZED_MEMBERS; diff --git a/Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift b/Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift index 906e5595..dd53f0cf 100644 --- a/Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift +++ b/Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift @@ -81,9 +81,15 @@ import SWBMacro swiftCompilerInfo: try mockSwiftCompilerSpec(swiftVersion: "5.6", swiftTag: "swiftlang-5.6.0.0") ) #expect(skipSynthesizedMembers == ["-symbol-graph-skip-synthesized-members"]) + + let skipInheritedDocs = await DocumentationCompilerSpec.additionalSymbolGraphGenerationArgs( + try mockApplicationBuildContext(application: false, skipInheritedDocs: true), + swiftCompilerInfo: try mockSwiftCompilerSpec(swiftVersion: "5.6", swiftTag: "swiftlang-5.6.0.0") + ) + #expect(skipInheritedDocs == ["-symbol-graph-skip-inherited-docs"]) } - private func mockApplicationBuildContext(application: Bool, minimumAccessLevel: DoccMinimumAccessLevel = .none, prettyPrint: Bool = false, skipSynthesizedMembers: Bool = false) async throws -> CommandBuildContext { + private func mockApplicationBuildContext(application: Bool, minimumAccessLevel: DoccMinimumAccessLevel = .none, prettyPrint: Bool = false, skipSynthesizedMembers: Bool = false, skipInheritedDocs: Bool = false) async throws -> CommandBuildContext { let core = try await getCore() let producer = try MockCommandProducer( @@ -107,6 +113,10 @@ import SWBMacro mockTable.push(BuiltinMacros.DOCC_SKIP_SYNTHESIZED_MEMBERS, literal: skipSynthesizedMembers) } + if skipInheritedDocs { + mockTable.push(BuiltinMacros.DOCC_SKIP_INHERITED_DOCS, literal: true) + } + let mockScope = MacroEvaluationScope(table: mockTable) return CommandBuildContext(producer: producer, scope: mockScope, inputs: [])