Skip to content

Commit 5e2eb78

Browse files
refactor: changes to standardize code with the strategy used in swiftlang#34
1 parent debd20c commit 5e2eb78

File tree

3 files changed

+12
-37
lines changed

3 files changed

+12
-37
lines changed

Sources/SwiftDocCPluginUtilities/ParsedArguments.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,13 @@ public struct ParsedArguments {
153153
/// Creates a new set of parsed arguments with the given arguments.
154154
public init(_ arguments: [String]) {
155155
self.arguments = arguments
156-
157156
let symbolGraphArguments = arguments.filter(for: .dumpSymbolGraph)
158157

159158
self.symbolGraphArguments = ParsedArguments.ArgumentConsumer.dumpSymbolGraph.flags.filter { option in
160159
option.parsedValues.contains(where: symbolGraphArguments.contains)
161160
}
162161
}
163162

164-
// Build array with plugin flags that modify the symbol graph generation,
165-
// filtering from the available custom symbol graph options those
166-
// that correspond to the received flags
167-
var symbolGraphArguments: [PluginFlag]
168-
169163
/// The command-line options required by the `docc` tool.
170164
private static let requiredOptions: [CommandLineOption] = [
171165
.fallbackDisplayName,
@@ -180,19 +174,14 @@ public struct ParsedArguments {
180174
"--index",
181175
]
182176

183-
/// The plugin-flag options to customize the Symbol Graph generation
184-
let customSymbolGraphOptions: [PluginFlag] = [
185-
.skipSynthesizedSymbols
186-
]
187-
188177
// Build array with plugin flags that modify the symbol graph generation,
189178
// filtering from the available custom symbol graph options those
190179
// that correspond to the received flags
191180
var symbolGraphArguments: [PluginFlag]
192181

193182
private static let argumentsTransformers: [ArgumentsTransforming] = [
194183
PluginFlag.disableIndex,
195-
PluginFlag.extendedTypes
184+
PluginFlag.extendedTypes,
196185
PluginFlag.skipSynthesizedSymbols
197186
]
198187
}
@@ -212,7 +201,8 @@ private extension ParsedArguments {
212201
switch self {
213202
case .dumpSymbolGraph:
214203
return [
215-
PluginFlag.extendedTypes
204+
PluginFlag.extendedTypes,
205+
PluginFlag.skipSynthesizedSymbols
216206
]
217207
case .docc:
218208
return []

Tests/SwiftDocCPluginUtilitiesTests/HelpInformationTests.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ final class HelpInformationTests: XCTestCase {
2121
doccExecutableURL: URL(fileURLWithPath: "/")
2222
)
2323

24+
print("includeExtendedTypesSection")
25+
print(includeExtendedTypesSection)
26+
2427
XCTAssertEqual(
2528
convertHelpInformation,
2629
"""
@@ -42,8 +45,7 @@ final class HelpInformationTests: XCTestCase {
4245
Produces a DocC archive that is best-suited for hosting online but incompatible with Xcode.
4346
--experimental-skip-synthesized-symbols
4447
Exclude synthesized symbols from the generated documentation
45-
Experimental feature that produces a DocC archive without compiler synthesized symbols.
46-
Produces a DocC archive that is best-suited for hosting online but incompatible with Xcode.\(includeExtendedTypesSection)
48+
Experimental feature that produces a DocC archive without compiler synthesized symbols.\(includeExtendedTypesSection)
4749
4850
DOCC OPTIONS:
4951
--platform <platform> Set the current release version of a platform.
@@ -135,8 +137,7 @@ final class HelpInformationTests: XCTestCase {
135137
Produces a DocC archive that is best-suited for hosting online but incompatible with Xcode.
136138
--experimental-skip-synthesized-symbols
137139
Exclude synthesized symbols from the generated documentation
138-
Experimental feature that produces a DocC archive without compiler synthesized symbols.
139-
Produces a DocC archive that is best-suited for hosting online but incompatible with Xcode.\(includeExtendedTypesSection)
140+
Experimental feature that produces a DocC archive without compiler synthesized symbols.\(includeExtendedTypesSection)
140141
141142
DOCC OPTIONS:
142143
--platform <platform> Set the current release version of a platform.

Tests/SwiftDocCPluginUtilitiesTests/ParsedArgumentsTests.swift

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ final class ParsedArgumentsTests: XCTestCase {
444444
}
445445

446446
func testDocCArgumentsWithDumpSymbolGraphArguments() {
447-
let dumpSymbolGraphArguments = ParsedArguments(["--include-extended-types"])
447+
let dumpSymbolGraphArguments = ParsedArguments(["--include-extended-types", "--experimental-skip-synthesized-symbols"])
448448

449449
let doccArguments = dumpSymbolGraphArguments.doccArguments(
450450
action: .convert,
@@ -455,30 +455,14 @@ final class ParsedArgumentsTests: XCTestCase {
455455
outputPath: "/my/output-path"
456456
)
457457

458-
XCTAssertFalse(doccArguments.contains("--include-extended-types"))
458+
XCTAssertFalse(doccArguments.contains("--experimental-skip-synthesized-symbols"))
459459
}
460460

461461
func testDumpSymbolGraphArguments() {
462-
let dumpSymbolGraphArguments = ParsedArguments(["--include-extended-types"])
462+
let dumpSymbolGraphArguments = ParsedArguments(["--include-extended-types", "--experimental-skip-synthesized-symbols"])
463463

464-
XCTAssertEqual(dumpSymbolGraphArguments.symbolGraphArguments, [.extendedTypes])
464+
XCTAssertEqual(dumpSymbolGraphArguments.symbolGraphArguments, [.extendedTypes, .skipSynthesizedSymbols])
465465
}
466-
467-
func testDocCSymbolGraphArgumentsForSynthesizedSymbols() {
468-
let excludeSynthesizedSymbolsArguments = ParsedArguments(
469-
["--experimental-skip-synthesized-symbols"]
470-
)
471-
XCTAssertEqual(
472-
excludeSynthesizedSymbolsArguments.symbolGraphArguments,
473-
[.skipSynthesizedSymbols]
474-
)
475-
let emptyArguments = ParsedArguments(
476-
[]
477-
)
478-
XCTAssertNotEqual(
479-
emptyArguments.symbolGraphArguments,
480-
[.skipSynthesizedSymbols]
481-
)
482466
func testDumpSymbolGraphArgumentsWithDocCArguments() {
483467
let dumpSymbolGraphArguments = ParsedArguments(["--fallback-default-module-kind", "Executable"])
484468

0 commit comments

Comments
 (0)