Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
feat: move ToC to top, add all headings
Lars Wirzenius committed 1 year ago
commit 5f7eba89cf53355887ff2ae8bc0d239067ed7e67
parent 423d4ae
1 file changed +18 -16
modified src/runlog.rs
@@ -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);
        }