Suppress mod doc comment with empty [doc]
attribute (#2254)
This commit is contained in:
parent
d5ebc9515e
commit
ea26e451fa
@ -96,7 +96,7 @@ impl<'src> Analyzer<'src> {
|
||||
let mut doc_attr: Option<&str> = None;
|
||||
for attribute in attributes {
|
||||
if let Attribute::Doc(ref doc) = attribute {
|
||||
doc_attr = doc.as_ref().map(|s| s.cooked.as_ref());
|
||||
doc_attr = Some(doc.as_ref().map(|s| s.cooked.as_ref()).unwrap_or_default());
|
||||
} else {
|
||||
return Err(name.token.error(InvalidAttribute {
|
||||
item_kind: "Module",
|
||||
|
@ -452,7 +452,7 @@ impl Subcommand {
|
||||
signature_widths: &BTreeMap<&str, usize>,
|
||||
) {
|
||||
if let Some(doc) = doc {
|
||||
if doc.lines().count() <= 1 {
|
||||
if !doc.is_empty() && doc.lines().count() <= 1 {
|
||||
print!(
|
||||
"{:padding$}{} {}",
|
||||
"",
|
||||
|
@ -787,3 +787,20 @@ fn bad_module_attribute_fails() {
|
||||
.status(EXIT_FAILURE)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_doc_attribute_on_module() {
|
||||
Test::new()
|
||||
.write("foo.just", "")
|
||||
.justfile(
|
||||
r#"
|
||||
# Suppressed comment
|
||||
[doc]
|
||||
mod foo
|
||||
"#,
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
.stdout("Available recipes:\n foo ...\n")
|
||||
.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user