diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-21 13:59:41 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-21 13:59:41 +0900 |
| commit | 72ae00bc1df1e2f5b9a68d608347a0aa9b0dede5 (patch) | |
| tree | d21709c3bafac1c52010fab8dc458bd64f8d6052 | |
| parent | 89c98cd6b4d92e0237a91eb18754d03dbe64fb6a (diff) | |
| parent | 243c8e91cffa9acfbbf8c1a81e5af0d8e6498299 (diff) | |
| download | rust-72ae00bc1df1e2f5b9a68d608347a0aa9b0dede5.tar.gz rust-72ae00bc1df1e2f5b9a68d608347a0aa9b0dede5.zip | |
Rollup merge of #78094 - camelid:rustdoc-fix-source-title, r=jyn514
rustdoc: Show the correct source filename in page titles, without `.html`
Previously the title would be
lib.rs.html -- source
if `lib.rs` was the actual source filename. Now the title is
lib.rs - source
| -rw-r--r-- | src/librustdoc/html/sources.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 02a7362bb3b..b487b399521 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -84,7 +84,7 @@ impl<'a> SourceCollector<'a> { }; // Remove the utf-8 BOM if any - if contents.starts_with("\u{feff}") { + if contents.starts_with('\u{feff}') { contents.drain(..3); } @@ -99,16 +99,15 @@ impl<'a> SourceCollector<'a> { href.push('/'); }); self.scx.ensure_dir(&cur)?; - let mut fname = p.file_name().expect("source has no filename").to_os_string(); + + let src_fname = p.file_name().expect("source has no filename").to_os_string(); + let mut fname = src_fname.clone(); fname.push(".html"); cur.push(&fname); href.push_str(&fname.to_string_lossy()); - let title = format!( - "{} -- source", - cur.file_name().expect("failed to get file name").to_string_lossy() - ); - let desc = format!("Source to the Rust file `{}`.", filename); + let title = format!("{} - source", src_fname.to_string_lossy()); + let desc = format!("Source of the Rust file `{}`.", filename); let page = layout::Page { title: &title, css_class: "source", |
