Skip to content

Commit b5d167f

Browse files
Add default favicon for documentation
1 parent 2200fd3 commit b5d167f

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/librustdoc/html/layout.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
191191
description = page.description,
192192
keywords = page.keywords,
193193
favicon = if layout.favicon.is_empty() {
194-
String::new()
194+
format!(r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
195+
static_root_path=static_root_path,
196+
suffix=page.resource_suffix)
195197
} else {
196198
format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
197199
},

src/librustdoc/html/render.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,10 @@ fn write_shared(
793793
write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)),
794794
static_files::RUST_LOGO)?;
795795
}
796+
if (*cx.shared).layout.favicon.is_empty() {
797+
write(cx.dst.join(&format!("favicon{}.ico", cx.shared.resource_suffix)),
798+
static_files::RUST_FAVICON)?;
799+
}
796800
write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)),
797801
static_files::BRUSH_SVG)?;
798802
write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)),
@@ -1999,8 +2003,6 @@ impl Context {
19992003
themes.push(PathBuf::from("settings.css"));
20002004
let mut layout = self.shared.layout.clone();
20012005
layout.krate = String::new();
2002-
layout.logo = String::new();
2003-
layout.favicon = String::new();
20042006
try_err!(layout::render(&mut w, &layout,
20052007
&page, &sidebar, &settings,
20062008
self.shared.css_file_extension.is_some(),
22.7 KB
Binary file not shown.

src/librustdoc/html/static_files.rs

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt")
5353

5454
/// The contents of `rust-logo.png`, the default icon of the documentation.
5555
pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png");
56+
/// The contents of `favicon.ico`, the default favicon of the documentation.
57+
pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico");
5658

5759
/// The built-in themes given to every documentation site.
5860
pub mod themes {

0 commit comments

Comments
 (0)