refactor: make code to create the preamble clearer

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-11-11 12:17:23 +02:00
parent 5f7eba89cf
commit 3366fc9074
+24 -27
View File
@@ -114,40 +114,37 @@ impl RunLog {
doc.push_to_head(Element::new(Tag::Title).with_text(title));
doc.push_to_body(Element::new(Tag::H1).with_text(title));
let mut ul = Element::new(Tag::Ul);
ul.push_child(
Element::new(Tag::Li)
.with_text("Repository id: ")
.with_child(Element::new(Tag::Code).with_text(&rid.to_string()))
.with_text(" ")
.with_text(repo_name),
);
ul.push_child(
Element::new(Tag::Li)
.with_text("Commit: ")
.with_child(Element::new(Tag::Code).with_text(&commit.to_string())),
);
if let Some(branch) = &self.branch {
ul.push_child(
let ul = Element::new(Tag::Ul)
.with_child(
Element::new(Tag::Li)
.with_text("Repository id: ")
.with_child(Element::new(Tag::Code).with_text(&rid.to_string()))
.with_text(" ")
.with_text(repo_name),
)
.with_child(
Element::new(Tag::Li)
.with_text("Commit: ")
.with_child(Element::new(Tag::Code).with_text(&commit.to_string())),
)
.with_child(if let Some(branch) = &self.branch {
Element::new(Tag::Li)
.with_text("Branch: ")
.with_child(Element::new(Tag::Code).with_text(branch)),
);
}
if let Some((patch, title)) = &self.patch {
ul.push_child(
.with_child(Element::new(Tag::Code).with_text(branch))
} else if let Some((patch, title)) = &self.patch {
Element::new(Tag::Li)
.with_text("Patch: ")
.with_child(Element::new(Tag::Code).with_text(&patch.to_string()))
.with_text(" ")
.with_text(title),
.with_text(title)
} else {
Element::new(Tag::Span)
})
.with_child(
Element::new(Tag::Li)
.with_text("Result: ")
.with_child(Element::new(Tag::B).with_text(self.result())),
);
}
ul.push_child(
Element::new(Tag::Li)
.with_text("Result: ")
.with_child(Element::new(Tag::B).with_text(self.result())),
);
doc.push_to_body(ul);
let mut toc = ToC::default();