Skip to content

Commit

Permalink
Rollup merge of #75438 - Cldfire:rustdoc/use-adaptive-svg-favicon, r=…
Browse files Browse the repository at this point in the history
…GuillaumeGomez

Use adaptive SVG favicon for rustdoc like other rust sites

Use the theme-adaptive SVG favicon that was recently introduced [for the Rust site](rust-lang/www.rust-lang.org#1185) (and others).

(This PR is simply copied from the PR linked above, so see that for rationale.)

Closes #72165.

Before, Firefox on Linux:

![image](https://user-images.githubusercontent.com/13814214/89971811-34c0a900-dc2a-11ea-9aa6-a4aa9d66bed4.png)

After, Firefox on Linux (`prefers-color-scheme` set to `dark` by setting `ui.systemUsesDarkTheme` to a number value of `1` in `about:config`):

![image](https://user-images.githubusercontent.com/13814214/89971842-515ce100-dc2a-11ea-92e8-c374aaaf6031.png)
  • Loading branch information
jonas-schievink authored Sep 25, 2020
2 parents e599b53 + 085679c commit 15efed4
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ pub fn render<T: Print, S: Print>(
keywords = page.keywords,
favicon = if layout.favicon.is_empty() {
format!(
r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
r##"<link rel="icon" type="image/svg+xml" href="{static_root_path}favicon{suffix}.svg">
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-16x16{suffix}.png">
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-32x32{suffix}.png">"##,
static_root_path = static_root_path,
suffix = page.resource_suffix
)
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ fn write_shared(
write(cx.path("rust-logo.png"), static_files::RUST_LOGO)?;
}
if (*cx.shared).layout.favicon.is_empty() {
write(cx.path("favicon.ico"), static_files::RUST_FAVICON)?;
write(cx.path("favicon.svg"), static_files::RUST_FAVICON_SVG)?;
write(cx.path("favicon-16x16.png"), static_files::RUST_FAVICON_PNG_16)?;
write(cx.path("favicon-32x32.png"), static_files::RUST_FAVICON_PNG_32)?;
}
write(cx.path("brush.svg"), static_files::BRUSH_SVG)?;
write(cx.path("wheel.svg"), static_files::WHEEL_SVG)?;
Expand Down
Binary file added src/librustdoc/html/static/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/librustdoc/html/static/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/librustdoc/html/static/favicon.ico
Binary file not shown.
24 changes: 24 additions & 0 deletions src/librustdoc/html/static/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/librustdoc/html/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");

/// The contents of `rust-logo.png`, the default icon of the documentation.
pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
/// The contents of `favicon.ico`, the default favicon of the documentation.
pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico");
/// The default documentation favicons (SVG and PNG fallbacks)
pub static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
pub static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
pub static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");

/// The built-in themes given to every documentation site.
pub mod themes {
Expand Down

0 comments on commit 15efed4

Please sign in to comment.