Add template for print_item

Add print_item.html and the code in print_item.rs to use it.
This commit is contained in:
Jacob Hoffman-Andrews
2021-10-08 21:57:44 -07:00
parent f8751436ff
commit 7a938005e1
4 changed files with 96 additions and 46 deletions

View File

@@ -33,7 +33,7 @@ use crate::formats::FormatRenderer;
use crate::html::escape::Escape;
use crate::html::format::Buffer;
use crate::html::markdown::{self, plain_text_summary, ErrorCodes, IdMap};
use crate::html::static_files::PAGE;
use crate::html::static_files::{PAGE, PRINT_ITEM};
use crate::html::{layout, sources};
/// Major driving force in all rustdoc rendering. This contains information
@@ -225,7 +225,7 @@ impl<'tcx> Context<'tcx> {
&self.shared.layout,
&page,
|buf: &mut _| print_sidebar(self, it, buf),
|buf: &mut _| print_item(self, it, buf, &page),
|buf: &mut _| print_item(self, &self.shared.templates, it, buf, &page),
&self.shared.style_files,
)
} else {
@@ -422,6 +422,10 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
file: "page.html".into(),
error: format!("{}: {}", e, e.source().map(|e| e.to_string()).unwrap_or_default()),
})?;
templates.add_raw_template("print_item.html", PRINT_ITEM).map_err(|e| Error {
file: "print_item.html".into(),
error: format!("{}: {}", e, e.source().map(|e| e.to_string()).unwrap_or_default()),
})?;
// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML