fix(macros/config/file_tree/markdown): Change format to align with mdfmt

To ensure, that `mdfmt` does not reformat our `expected.md` files.
This commit is contained in:
Benedikt Peetz 2024-03-26 17:23:59 +01:00
parent fa6b046780
commit 5855d9bcb0
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
1 changed files with 25 additions and 6 deletions

View File

@ -51,28 +51,47 @@ impl Display for Language {
impl Display for GeneratedFile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("File path: `{}`\n", self.path.display()))?;
f.write_fmt(format_args!("File path: `{}`\n\n", self.path.display()))?;
f.write_fmt(format_args!("```{}\n", self.language))?;
f.write_fmt(format_args!("{}", &self.value))?;
f.write_str("```\n\n")
f.write_str("```")
}
}
impl Display for FileTree {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut first = true;
if !self.host_files.is_empty() {
f.write_str("# Host files\n")?;
f.write_str("# Host files\n\n")?;
self.host_files
.iter()
.map(|file| -> std::fmt::Result { f.write_str(&file.to_string()) })
.map(|file| -> std::fmt::Result {
if !first {
f.write_str("\n\n")?;
} else {
first = false;
}
f.write_str(&file.to_string())
})
.collect::<std::fmt::Result>()?;
}
first = true;
if !self.auxiliary_files.is_empty() {
f.write_str("# Auxiliary files\n")?;
if !self.host_files.is_empty() {
f.write_str("\n\n")?;
}
f.write_str("# Auxiliary files\n\n")?;
self.auxiliary_files
.iter()
.map(|file| -> std::fmt::Result { f.write_str(&file.to_string()) })
.map(|file| -> std::fmt::Result {
if !first {
f.write_str("\n\n")?;
} else {
first = false;
}
f.write_str(&file.to_string())
})
.collect::<std::fmt::Result>()?;
}
Ok(())