summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/html/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html/layout.rs')
-rw-r--r--src/librustdoc/html/layout.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index 7d6d4b71e..a60e7cb10 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -2,13 +2,14 @@ use std::path::PathBuf;
use rustc_data_structures::fx::FxHashMap;
-use crate::error::Error;
use crate::externalfiles::ExternalHtml;
use crate::html::format::{Buffer, Print};
use crate::html::render::{ensure_trailing_slash, StylePath};
use askama::Template;
+use super::static_files::{StaticFiles, STATIC_FILES};
+
#[derive(Clone)]
pub(crate) struct Layout {
pub(crate) logo: String,
@@ -34,17 +35,23 @@ pub(crate) struct Page<'a> {
}
impl<'a> Page<'a> {
- pub(crate) fn get_static_root_path(&self) -> &str {
- self.static_root_path.unwrap_or(self.root_path)
+ pub(crate) fn get_static_root_path(&self) -> String {
+ match self.static_root_path {
+ Some(s) => s.to_string(),
+ None => format!("{}static.files/", self.root_path),
+ }
}
}
#[derive(Template)]
#[template(path = "page.html")]
struct PageLayout<'a> {
- static_root_path: &'a str,
+ static_root_path: String,
page: &'a Page<'a>,
layout: &'a Layout,
+
+ files: &'static StaticFiles,
+
themes: Vec<String>,
sidebar: String,
content: String,
@@ -61,19 +68,17 @@ pub(crate) fn render<T: Print, S: Print>(
) -> String {
let static_root_path = page.get_static_root_path();
let krate_with_trailing_slash = ensure_trailing_slash(&layout.krate).to_string();
- let mut themes: Vec<String> = style_files
- .iter()
- .map(StylePath::basename)
- .collect::<Result<_, Error>>()
- .unwrap_or_default();
+ let mut themes: Vec<String> = style_files.iter().map(|s| s.basename().unwrap()).collect();
themes.sort();
- let rustdoc_version = rustc_interface::util::version_str().unwrap_or("unknown version");
+
+ let rustdoc_version = rustc_interface::util::version_str!().unwrap_or("unknown version");
let content = Buffer::html().to_display(t); // Note: This must happen before making the sidebar.
let sidebar = Buffer::html().to_display(sidebar);
PageLayout {
static_root_path,
page,
layout,
+ files: &STATIC_FILES,
themes,
sidebar,
content,