diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 987cec6fbfa96..c34dcbbb672e9 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -177,7 +177,10 @@ pub fn render( root_path = page.root_path, css_class = page.css_class, logo = if layout.logo.is_empty() { - String::new() + format!("\ + logo", + static_root_path=static_root_path, + suffix=page.resource_suffix) } else { format!("\ logo", @@ -188,7 +191,9 @@ pub fn render( description = page.description, keywords = page.keywords, favicon = if layout.favicon.is_empty() { - String::new() + format!(r#""#, + static_root_path=static_root_path, + suffix=page.resource_suffix) } else { format!(r#""#, layout.favicon) }, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index ad1659be3460e..86fb51419c270 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -789,6 +789,14 @@ fn write_shared( themes.insert(theme.to_owned()); } + if (*cx.shared).layout.logo.is_empty() { + write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)), + static_files::RUST_LOGO)?; + } + if (*cx.shared).layout.favicon.is_empty() { + write(cx.dst.join(&format!("favicon{}.ico", cx.shared.resource_suffix)), + static_files::RUST_FAVICON)?; + } write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)), static_files::BRUSH_SVG)?; write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)), @@ -2068,8 +2076,6 @@ impl Context { themes.push(PathBuf::from("settings.css")); let mut layout = self.shared.layout.clone(); layout.krate = String::new(); - layout.logo = String::new(); - layout.favicon = String::new(); try_err!(layout::render(&mut w, &layout, &page, &sidebar, &settings, self.shared.css_file_extension.is_some(), diff --git a/src/librustdoc/html/static/favicon.ico b/src/librustdoc/html/static/favicon.ico new file mode 100644 index 0000000000000..b8ad23769ac8d Binary files /dev/null and b/src/librustdoc/html/static/favicon.ico differ diff --git a/src/librustdoc/html/static/rust-logo.png b/src/librustdoc/html/static/rust-logo.png new file mode 100644 index 0000000000000..74b4bd695045e Binary files /dev/null and b/src/librustdoc/html/static/rust-logo.png differ diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index f340590e5fe33..a1d8cfacc54ad 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -51,6 +51,11 @@ pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE /// The contents of `LICENSE-MIT.txt`, the text of the MIT License. pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt"); +/// The contents of `rust-logo.png`, the default icon of the documentation. +pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png"); +/// The contents of `favicon.ico`, the default favicon of the documentation. +pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico"); + /// The built-in themes given to every documentation site. pub mod themes { /// The "light" theme, selected by default when no setting is available. Used as the basis for