Migrate to Askama

This commit is contained in:
sladynnunes 2023-05-28 01:37:25 -07:00
parent 2560b80a08
commit 5c780d9926

View File

@ -1420,30 +1420,36 @@ fn item_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)) write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
} }
fn item_proc_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, m: &clean::ProcMacro) { fn item_proc_macro(
wrap_item(w, |w| { w: &mut impl fmt::Write,
cx: &mut Context<'_>,
it: &clean::Item,
m: &clean::ProcMacro,
) {
let mut buffer = Buffer::new();
wrap_item(&mut buffer, |buffer| {
let name = it.name.expect("proc-macros always have names"); let name = it.name.expect("proc-macros always have names");
match m.kind { match m.kind {
MacroKind::Bang => { MacroKind::Bang => {
write!(w, "{}!() {{ /* proc-macro */ }}", name); write!(buffer, "{}!() {{ /* proc-macro */ }}", name);
} }
MacroKind::Attr => { MacroKind::Attr => {
write!(w, "#[{}]", name); write!(buffer, "#[{}]", name);
} }
MacroKind::Derive => { MacroKind::Derive => {
write!(w, "#[derive({})]", name); write!(buffer, "#[derive({})]", name);
if !m.helpers.is_empty() { if !m.helpers.is_empty() {
w.push_str("\n{\n"); buffer.push_str("\n{\n");
w.push_str(" // Attributes available to this derive:\n"); buffer.push_str(" // Attributes available to this derive:\n");
for attr in &m.helpers { for attr in &m.helpers {
writeln!(w, " #[{}]", attr); writeln!(buffer, " #[{}]", attr);
} }
w.push_str("}\n"); buffer.push_str("}\n");
} }
} }
} }
}); });
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)) write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
} }
fn item_primitive(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) { fn item_primitive(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {