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
14 changes: 9 additions & 5 deletions crates/uv-dev/src/generate_cli_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut

// Do not display options for commands with children
if !has_subcommands {
let name_key = name.replace(' ', "-");

// Display positional arguments
let mut arguments = command
.get_positionals()
Expand All @@ -196,10 +198,11 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
output.push_str("<dl class=\"cli-reference\">");

for arg in arguments {
output.push_str("<dt>");
let id = format!("{name_key}--{}", arg.get_id());
output.push_str(&format!("<dt id=\"{id}\">"));
output.push_str(&format!(
"<code>{}</code>",
arg.get_id().to_string().to_uppercase()
"<a href=\"#{id}\"<code>{}</code></a>",
arg.get_id().to_string().to_uppercase(),
));
output.push_str("</dt>");
if let Some(help) = arg.get_long_help().or_else(|| arg.get_help()) {
Expand All @@ -225,9 +228,10 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
output.push_str("<dl class=\"cli-reference\">");
for opt in options {
let Some(long) = opt.get_long() else { continue };
let id = format!("{name_key}--{long}");

output.push_str("<dt>");
output.push_str(&format!("<code>--{long}</code>"));
output.push_str(&format!("<dt id=\"{id}\">"));
output.push_str(&format!("<a href=\"#{id}\"><code>--{long}</code></a>",));
if let Some(short) = opt.get_short() {
output.push_str(&format!(", <code>-{short}</code>"));
}
Expand Down
Loading
Loading