Skip to content

Commit e978a38

Browse files
authored
Default to single page manuals (#472)
- Changes the generate-manual --single-page argument to --multi-page, so generate-manual with create a single manual page with all subcommand information by default instead of many distinct files.
1 parent 4b93f3e commit e978a38

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

Sources/ArgumentParserTestHelpers/TestHelpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ extension XCTest {
325325
}
326326

327327
public func AssertGenerateManual(
328-
singlePage: Bool,
328+
multiPage: Bool,
329329
command: String,
330330
expected: String,
331331
file: StaticString = #file,
@@ -341,8 +341,8 @@ extension XCTest {
341341
"--authors", "The Appleseeds<[email protected]>",
342342
"--output-directory", "-",
343343
]
344-
if singlePage {
345-
command.append("--single-page")
344+
if multiPage {
345+
command.append("--multi-page")
346346
}
347347
try AssertExecuteCommand(
348348
command: command,

Tests/ArgumentParserGenerateManualTests/CountLinesGenerateManualTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import ArgumentParserTestHelpers
1717
final class CountLinesGenerateManualTests: XCTestCase {
1818
func testCountLines_SinglePageManual() throws {
1919
guard #available(macOS 12, *) else { return }
20-
try AssertGenerateManual(singlePage: true, command: "count-lines", expected: #"""
20+
try AssertGenerateManual(multiPage: false, command: "count-lines", expected: #"""
2121
.\" "Generated by swift-argument-parser"
2222
.Dd May 12, 1996
2323
.Dt COUNT-LINES 9
@@ -59,7 +59,7 @@ final class CountLinesGenerateManualTests: XCTestCase {
5959

6060
func testCountLines_MultiPageManual() throws {
6161
guard #available(macOS 12, *) else { return }
62-
try AssertGenerateManual(singlePage: false, command: "count-lines", expected: #"""
62+
try AssertGenerateManual(multiPage: true, command: "count-lines", expected: #"""
6363
.\" "Generated by swift-argument-parser"
6464
.Dd May 12, 1996
6565
.Dt COUNT-LINES 9

Tests/ArgumentParserGenerateManualTests/MathGenerateManualTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ArgumentParserTestHelpers
1515

1616
final class MathGenerateManualTests: XCTestCase {
1717
func testMath_SinglePageManual() throws {
18-
try AssertGenerateManual(singlePage: true, command: "math", expected: #"""
18+
try AssertGenerateManual(multiPage: false, command: "math", expected: #"""
1919
.\" "Generated by swift-argument-parser"
2020
.Dd May 12, 1996
2121
.Dt MATH 9
@@ -120,7 +120,7 @@ final class MathGenerateManualTests: XCTestCase {
120120
}
121121

122122
func testMath_MultiPageManual() throws {
123-
try AssertGenerateManual(singlePage: false, command: "math", expected: #"""
123+
try AssertGenerateManual(multiPage: true, command: "math", expected: #"""
124124
.\" "Generated by swift-argument-parser"
125125
.Dd May 12, 1996
126126
.Dt MATH 9

Tests/ArgumentParserGenerateManualTests/RepeatGenerateManualTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ArgumentParserTestHelpers
1414

1515
final class RepeatGenerateManualTests: XCTestCase {
1616
func testMath_SinglePageManual() throws {
17-
try AssertGenerateManual(singlePage: true, command: "repeat", expected: #"""
17+
try AssertGenerateManual(multiPage: false, command: "repeat", expected: #"""
1818
.\" "Generated by swift-argument-parser"
1919
.Dd May 12, 1996
2020
.Dt REPEAT 9
@@ -55,7 +55,7 @@ final class RepeatGenerateManualTests: XCTestCase {
5555
}
5656

5757
func testMath_MultiPageManual() throws {
58-
try AssertGenerateManual(singlePage: false, command: "repeat", expected: #"""
58+
try AssertGenerateManual(multiPage: true, command: "repeat", expected: #"""
5959
.\" "Generated by swift-argument-parser"
6060
.Dd May 12, 1996
6161
.Dt REPEAT 9

Tests/ArgumentParserGenerateManualTests/RollDiceGenerateManualTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ArgumentParserTestHelpers
1414

1515
final class RollDiceGenerateManualTests: XCTestCase {
1616
func testRollDice_SinglePageManual() throws {
17-
try AssertGenerateManual(singlePage: true, command: "roll", expected: #"""
17+
try AssertGenerateManual(multiPage: false, command: "roll", expected: #"""
1818
.\" "Generated by swift-argument-parser"
1919
.Dd May 12, 1996
2020
.Dt ROLL 9
@@ -60,7 +60,7 @@ final class RollDiceGenerateManualTests: XCTestCase {
6060
}
6161

6262
func testRollDice_MultiPageManual() throws {
63-
try AssertGenerateManual(singlePage: false, command: "roll", expected: #"""
63+
try AssertGenerateManual(multiPage: true, command: "roll", expected: #"""
6464
.\" "Generated by swift-argument-parser"
6565
.Dd May 12, 1996
6666
.Dt ROLL 9

Tools/generate-manual/DSL/Document.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ArgumentParserToolInfo
1414
import Foundation
1515

1616
struct Document: MDocComponent {
17-
var singlePage: Bool
17+
var multiPage: Bool
1818
var date: Date
1919
var section: Int
2020
var authors: [AuthorArgument]
@@ -24,13 +24,13 @@ struct Document: MDocComponent {
2424
Preamble(date: date, section: section, command: command)
2525
Name(command: command)
2626
Synopsis(command: command)
27-
if singlePage {
28-
SinglePageDescription(command: command)
29-
} else {
27+
if multiPage {
3028
MultiPageDescription(command: command)
29+
} else {
30+
SinglePageDescription(command: command)
3131
}
3232
Exit(section: section)
33-
if !singlePage {
33+
if multiPage {
3434
SeeAlso(section: section, command: command)
3535
}
3636
Authors(authors: authors)

Tools/generate-manual/GenerateManual.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ struct GenerateManual: ParsableCommand {
2929
@Argument(help: "Tool to generate manual for.")
3030
var tool: String
3131

32-
@Flag(help: "Generate a single page with information for all subcommands.")
33-
var singlePage = false
32+
@Flag(help: "Generate a separate manual for each subcommand.")
33+
var multiPage = false
3434

3535
@Option(name: .long, help: "Override the creation date of the manual. Format: 'yyyy-mm-dd'.")
3636
var date: Date = Date()
@@ -46,7 +46,7 @@ struct GenerateManual: ParsableCommand {
4646

4747
func validate() throws {
4848
// Only man pages 1 through 9 are valid.
49-
if !(1...9).contains(section) {
49+
guard (1...9).contains(section) else {
5050
throw ValidationError("Invalid manual section passed to --section")
5151
}
5252

@@ -106,7 +106,7 @@ struct GenerateManual: ParsableCommand {
106106

107107
func generatePages(from command: CommandInfoV0, savingTo directory: URL?) throws {
108108
let document = Document(
109-
singlePage: singlePage,
109+
multiPage: multiPage,
110110
date: date,
111111
section: section,
112112
authors: authors,
@@ -121,7 +121,7 @@ struct GenerateManual: ParsableCommand {
121121
print(page)
122122
}
123123

124-
if !singlePage {
124+
if multiPage {
125125
for subcommand in command.subcommands ?? [] {
126126
try generatePages(from: subcommand, savingTo: directory)
127127
}

0 commit comments

Comments
 (0)