Add SharedResource abstraction and use it in write_shared
This cleans up the code quite a bit, and also makes the next commit much easier.
This commit is contained in:
@@ -79,17 +79,6 @@ crate struct Context<'tcx> {
|
||||
rustc_data_structures::static_assert_size!(Context<'_>, 152);
|
||||
|
||||
impl<'tcx> Context<'tcx> {
|
||||
pub(super) fn path(&self, filename: &str) -> PathBuf {
|
||||
// We use splitn vs Path::extension here because we might get a filename
|
||||
// like `style.min.css` and we want to process that into
|
||||
// `style-suffix.min.css`. Path::extension would just return `css`
|
||||
// which would result in `style.min-suffix.css` which isn't what we
|
||||
// want.
|
||||
let (base, ext) = filename.split_once('.').unwrap();
|
||||
let filename = format!("{}{}.{}", base, self.shared.resource_suffix, ext);
|
||||
self.dst.join(&filename)
|
||||
}
|
||||
|
||||
pub(super) fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.shared.tcx
|
||||
}
|
||||
@@ -487,7 +476,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||
|buf: &mut Buffer| all.print(buf),
|
||||
&self.shared.style_files,
|
||||
);
|
||||
self.shared.fs.write(&final_file, v.as_bytes())?;
|
||||
self.shared.fs.write(final_file, v.as_bytes())?;
|
||||
|
||||
// Generating settings page.
|
||||
page.title = "Rustdoc settings";
|
||||
|
||||
Reference in New Issue
Block a user