-
Notifications
You must be signed in to change notification settings - Fork 14.1k
rustdoc: Show the correct source filename in page titles, without .html
#78094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
.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
(note the en dash).- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ use crate::html::layout; | |
| use crate::html::render::{SharedContext, BASIC_KEYWORDS}; | ||
| use rustc_hir::def_id::LOCAL_CRATE; | ||
| use rustc_span::source_map::FileName; | ||
| use std::ffi::OsStr; | ||
| use std::ffi::{OsStr, OsString}; | ||
| use std::fs; | ||
| use std::path::{Component, Path, PathBuf}; | ||
|
|
||
|
|
@@ -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(); | ||
| fname.push(".html"); | ||
|
|
||
| let src_fname = | ||
| String::from(p.file_name().expect("source has no filename").to_string_lossy()); | ||
| let fname = OsString::from(src_fname.clone() + ".html"); | ||
camelid marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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,); | ||
|
||
| let desc = format!("Source of the Rust file `{}`.", filename); | ||
| let page = layout::Page { | ||
| title: &title, | ||
| css_class: "source", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.