Skip to content

display arguments as term lists in docc-flavored markdown generation #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2025
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
22 changes: 16 additions & 6 deletions Sources/ArgumentParserTestHelpers/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ extension XCTest {
ProcessInfo.processInfo.environment["RECORD_SNAPSHOTS"] != nil

if record || recordEnvironment || !snapshotExists {
let recordedValue = actual + "\n"
let recordedValue = actual
try FileManager.default.createDirectory(
at: snapshotDirectoryURL,
withIntermediateDirectories: true,
Expand Down Expand Up @@ -507,8 +507,9 @@ extension XCTest {
line: line)
}

public func assertGenerateDoccReference(
public func assertGeneratedReference(
command: String,
doccFlavored: Bool,
record: Bool = false,
test: StaticString = #function,
file: StaticString = #filePath,
Expand All @@ -519,10 +520,19 @@ extension XCTest {
#endif

let commandURL = debugURL.appendingPathComponent(command)
let command = [
"generate-docc-reference", commandURL.path,
"--output-directory", "-",
]
let command: [String]
if doccFlavored {
command = [
"generate-docc-reference", commandURL.path,
"--output-directory", "-",
"--style", "docc",
]
} else {
command = [
"generate-docc-reference", commandURL.path,
"--output-directory", "-",
]
}
let actual = try AssertExecuteCommand(
command: command,
file: file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,42 @@ import XCTest

final class GenerateDoccReferenceTests: XCTestCase {
#if os(macOS)
func testCountLinesMarkdownReference() throws {
guard #available(macOS 12, *) else { return }
try assertGeneratedReference(command: "count-lines", doccFlavored: false)
}

func testCountLinesDoccReference() throws {
guard #available(macOS 12, *) else { return }
try assertGenerateDoccReference(command: "count-lines")
try assertGeneratedReference(command: "count-lines", doccFlavored: true)
}
#endif

func testColorMarkdownReference() throws {
try assertGeneratedReference(command: "color", doccFlavored: false)
}
func testColorDoccReference() throws {
try assertGenerateDoccReference(command: "color")
try assertGeneratedReference(command: "color", doccFlavored: true)
}

func testMathMarkdownReference() throws {
try assertGeneratedReference(command: "math", doccFlavored: false)
}
func testMathDoccReference() throws {
try assertGenerateDoccReference(command: "math")
try assertGeneratedReference(command: "math", doccFlavored: true)
}

func testRepeatMarkdownReference() throws {
try assertGeneratedReference(command: "repeat", doccFlavored: false)
}
func testRepeatDoccReference() throws {
try assertGenerateDoccReference(command: "repeat")
try assertGeneratedReference(command: "repeat", doccFlavored: true)
}

func testRollMarkdownReference() throws {
try assertGeneratedReference(command: "roll", doccFlavored: false)
}
func testRollDoccReference() throws {
try assertGenerateDoccReference(command: "roll")
try assertGeneratedReference(command: "roll", doccFlavored: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
color --fav=<fav> [--second=<second>] [--help]
```

**--fav=\<fav\>:**
- term **--fav=\<fav\>:**

*Your favorite color.*


**--second=\<second\>:**
- term **--second=\<second\>:**

*Your second favorite color.*

This is optional.


**--help:**
- term **--help:**

*Show help information.*

Expand All @@ -31,7 +31,7 @@ Show subcommand help information.
color help [<subcommands>...]
```

**subcommands:**
- term **subcommands:**



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# color

<!-- Generated by swift-argument-parser -->

```
color --fav=<fav> [--second=<second>] [--help]
```

**--fav=\<fav\>:**

*Your favorite color.*


**--second=\<second\>:**

*Your second favorite color.*

This is optional.


**--help:**

*Show help information.*


## color.help

Show subcommand help information.

```
color help [<subcommands>...]
```

**subcommands:**





Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
count-lines [<input-file>] [--prefix=<prefix>] [--verbose] [--help]
```

**input-file:**
- term **input-file:**

*A file to count lines in. If omitted, counts the lines of stdin.*


**--prefix=\<prefix\>:**
- term **--prefix=\<prefix\>:**

*Only count lines with this prefix.*


**--verbose:**
- term **--verbose:**

*Include extra information in the output.*


**--help:**
- term **--help:**

*Show help information.*

Expand All @@ -34,7 +34,7 @@ Show subcommand help information.
count-lines help [<subcommands>...]
```

**subcommands:**
- term **subcommands:**



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# count-lines

<!-- Generated by swift-argument-parser -->

```
count-lines [<input-file>] [--prefix=<prefix>] [--verbose] [--help]
```

**input-file:**

*A file to count lines in. If omitted, counts the lines of stdin.*


**--prefix=\<prefix\>:**

*Only count lines with this prefix.*


**--verbose:**

*Include extra information in the output.*


**--help:**

*Show help information.*


## count-lines.help

Show subcommand help information.

```
count-lines help [<subcommands>...]
```

**subcommands:**





Loading