Print multi-line doc comments before recipe in --list
(#2090)
This commit is contained in:
parent
16a27dba87
commit
2bacbddadb
@ -566,19 +566,33 @@ impl Subcommand {
|
||||
.chain(aliases.get(recipe.name()).unwrap_or(&Vec::new()))
|
||||
.enumerate()
|
||||
{
|
||||
print!(
|
||||
"{}{}",
|
||||
config.list_prefix.repeat(level + 1),
|
||||
RecipeSignature { name, recipe }.color_display(config.color.stdout())
|
||||
);
|
||||
|
||||
let doc = if i == 0 {
|
||||
recipe.doc().map(Cow::Borrowed)
|
||||
} else {
|
||||
Some(Cow::Owned(format!("alias for `{}`", recipe.name)))
|
||||
};
|
||||
|
||||
if let Some(doc) = &doc {
|
||||
if doc.lines().count() > 1 {
|
||||
for line in doc.lines() {
|
||||
println!(
|
||||
"{}{} {}",
|
||||
config.list_prefix.repeat(level + 1),
|
||||
config.color.stdout().doc().paint("#"),
|
||||
config.color.stdout().doc().paint(line),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print!(
|
||||
"{}{}",
|
||||
config.list_prefix.repeat(level + 1),
|
||||
RecipeSignature { name, recipe }.color_display(config.color.stdout())
|
||||
);
|
||||
|
||||
if let Some(doc) = doc {
|
||||
if doc.lines().count() <= 1 {
|
||||
print!(
|
||||
"{:padding$}{} {}",
|
||||
"",
|
||||
@ -587,6 +601,7 @@ impl Subcommand {
|
||||
padding = max_signature_width.saturating_sub(signature_widths[name]) + 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
@ -171,3 +171,25 @@ fn doc_attribute_suppress() {
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_multiline() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[doc('multiline
|
||||
comment')]
|
||||
foo:
|
||||
",
|
||||
)
|
||||
.args(["--list"])
|
||||
.stdout(
|
||||
"
|
||||
Available recipes:
|
||||
# multiline
|
||||
# comment
|
||||
foo
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user