Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<DoccMinimumAccessLevel>
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")
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions Sources/SWBUniversalPlatform/Specs/Documentation.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion Tests/SWBCoreTests/DocumentationCompilerSpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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: [])
Expand Down
Loading