Skip to content

Commit 2200fd3

Browse files
Add default rust logo for documentation
1 parent ceb2512 commit 2200fd3

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/librustdoc/html/layout.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
177177
root_path = page.root_path,
178178
css_class = page.css_class,
179179
logo = if layout.logo.is_empty() {
180-
String::new()
180+
format!("<a href='{}{}/index.html'>\
181+
<img src='{static_root_path}rust-logo{suffix}.png' alt='logo' width='100'></a>",
182+
static_root_path=static_root_path,
183+
suffix=page.resource_suffix)
181184
} else {
182185
format!("<a href='{}{}/index.html'>\
183186
<img src='{}' alt='logo' width='100'></a>",

src/librustdoc/html/render.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,10 @@ fn write_shared(
789789
themes.insert(theme.to_owned());
790790
}
791791

792+
if (*cx.shared).layout.logo.is_empty() {
793+
write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)),
794+
static_files::RUST_LOGO)?;
795+
}
792796
write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)),
793797
static_files::BRUSH_SVG)?;
794798
write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)),
5.62 KB
Loading

src/librustdoc/html/static_files.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE
5151
/// The contents of `LICENSE-MIT.txt`, the text of the MIT License.
5252
pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt");
5353

54+
/// The contents of `rust-logo.png`, the default icon of the documentation.
55+
pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png");
56+
5457
/// The built-in themes given to every documentation site.
5558
pub mod themes {
5659
/// The "light" theme, selected by default when no setting is available. Used as the basis for

0 commit comments

Comments
 (0)