feat: move ToC to top, add all headings

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-11-11 12:11:32 +02:00
parent 423d4aeea9
commit 5f7eba89cf
+18 -16
View File
@@ -150,39 +150,41 @@ impl RunLog {
);
doc.push_to_body(ul);
doc.push_to_body(Element::new(Tag::H2).with_text("Request message"));
let mut toc = ToC::default();
let mut body = Element::new(Tag::Div);
body.push_child(
toc.push(
Element::new(Tag::Span)
.with_child(Element::new(Tag::Code).with_text("Request message")),
),
);
let req = serde_json::to_string_pretty(&self.request).unwrap();
let req = Element::new(Tag::Pre).with_text(&req);
doc.push_to_body(req);
body.push_child(req);
if let Some(e) = &self.runspec_error {
let error = Element::new(Tag::P)
.with_text("Failed to load .radicle/native.yaml: ")
.with_child(Element::new(Tag::Code).with_text(e));
doc.push_to_body(error);
body.push_child(error);
}
if self.timeout {
let timeout = Element::new(Tag::P).with_text("Last command timed out");
doc.push_to_body(timeout);
body.push_child(timeout);
}
if let Some(runspec) = &self.runspec {
let text = serde_yaml::to_string(&runspec).map_err(RunLogError::RunSpec)?;
let native_yaml = Element::new(Tag::Div)
.with_child(
Element::new(Tag::H2)
.with_child(Element::new(Tag::Code).with_text(RUNSPEC_PATH)),
)
.with_child(
Element::new(Tag::Blockquote)
.with_child(Element::new(Tag::Pre).with_text(&text)),
);
doc.push_to_body(native_yaml);
body.push_child(toc.push(Element::new(Tag::Span).with_child(
Element::new(Tag::Code).with_child(Element::new(Tag::Code).with_text(RUNSPEC_PATH)),
)));
body.push_child(
Element::new(Tag::Blockquote).with_child(Element::new(Tag::Pre).with_text(&text)),
);
}
let mut toc = ToC::default();
let mut body = Element::new(Tag::Div);
for cmd in self.commands.iter() {
cmd.format(&mut body, &mut toc);
}