Skip to content

Add subcommand abstract to single-page manuals #552

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 1 commit into from
Feb 15, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class MathGenerateManualTests: XCTestCase {
.It Fl h , -help
Show help information.
.It Em add
Print the sum of the values.
.Bl -tag -width 6n
.It Fl x , -hex-output
Use hexadecimal notation for the result.
Expand All @@ -46,6 +47,7 @@ final class MathGenerateManualTests: XCTestCase {
Show help information.
.El
.It Em multiply
Print the product of the values.
.Bl -tag -width 6n
.It Fl x , -hex-output
Use hexadecimal notation for the result.
Expand All @@ -57,12 +59,14 @@ final class MathGenerateManualTests: XCTestCase {
Show help information.
.El
.It Em stats
Calculate descriptive statistics.
.Bl -tag -width 6n
.It Fl -version
Show the version.
.It Fl h , -help
Show help information.
.It Em average
Print the average of the values.
.Bl -tag -width 6n
.It Fl -kind Ar kind
The kind of average to provide.
Expand All @@ -74,6 +78,7 @@ final class MathGenerateManualTests: XCTestCase {
Show help information.
.El
.It Em stdev
Print the standard deviation of the values.
.Bl -tag -width 6n
.It Ar values...
A group of floating-point values to operate on.
Expand All @@ -83,6 +88,7 @@ final class MathGenerateManualTests: XCTestCase {
Show help information.
.El
.It Em quantiles
Print the quantiles of the values (TBD).
.Bl -tag -width 6n
.It Ar one-of-four
.It Ar custom-arg
Expand Down
2 changes: 1 addition & 1 deletion Tools/generate-manual/DSL/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct Document: MDocComponent {
if multiPage {
MultiPageDescription(command: command)
} else {
SinglePageDescription(command: command)
SinglePageDescription(command: command, root: true)
}
Exit(section: section)
if multiPage {
Expand Down
11 changes: 10 additions & 1 deletion Tools/generate-manual/DSL/SinglePageDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ArgumentParserToolInfo

struct SinglePageDescription: MDocComponent {
var command: CommandInfoV0
var root: Bool

var body: MDocComponent {
Section(title: "description") {
Expand All @@ -23,6 +24,14 @@ struct SinglePageDescription: MDocComponent {

@MDocBuilder
var core: MDocComponent {
if !root, let abstract = command.abstract {
abstract
}

if !root, command.abstract != nil, command.discussion != nil {
MDocMacro.ParagraphBreak()
}

if let discussion = command.discussion {
discussion
}
Expand All @@ -46,7 +55,7 @@ struct SinglePageDescription: MDocComponent {

for subcommand in command.subcommands ?? [] {
MDocMacro.ListItem(title: MDocMacro.Emphasis(arguments: [subcommand.commandName]))
SinglePageDescription(command: subcommand).core
SinglePageDescription(command: subcommand, root: false).core
}
}
}
Expand Down