diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-01-12 22:27:09 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-01-20 21:47:43 +0100 |
| commit | b5d167f58a423cb0003714eceeb72172d1726473 (patch) | |
| tree | 87886d4ee78564b1c05fbd1b321a4900e31a332d | |
| parent | 2200fd3c7caf19323e7bd4cf649e4ec53d1de369 (diff) | |
| download | rust-b5d167f58a423cb0003714eceeb72172d1726473.tar.gz rust-b5d167f58a423cb0003714eceeb72172d1726473.zip | |
Add default favicon for documentation
| -rw-r--r-- | src/librustdoc/html/layout.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/html/static/favicon.ico | bin | 0 -> 23229 bytes | |||
| -rw-r--r-- | src/librustdoc/html/static_files.rs | 2 |
4 files changed, 9 insertions, 3 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index b7af28fbcc8..c34dcbbb672 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -191,7 +191,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>( description = page.description, keywords = page.keywords, favicon = if layout.favicon.is_empty() { - String::new() + format!(r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#, + static_root_path=static_root_path, + suffix=page.resource_suffix) } else { format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon) }, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d050b706f10..b64ac950963 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -793,6 +793,10 @@ fn write_shared( 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)), @@ -1999,8 +2003,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 00000000000..b8ad23769ac --- /dev/null +++ b/src/librustdoc/html/static/favicon.ico Binary files differdiff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index bd048d2ec97..a1d8cfacc54 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -53,6 +53,8 @@ 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 { |
