1
Fork 0

Rollup merge of #57929 - GuillaumeGomez:rustodc-remove-old-style-files, r=ollie27

Rustdoc remove old style files

Reopening of #56577 (which I can't seem to reopen...).

I made the flag unstable so with this change, what was blocking the PR is now gone I assume.
This commit is contained in:
kennytm 2019-02-16 14:15:04 +08:00
commit f8ccdeb0d4
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
13 changed files with 64 additions and 23 deletions

View file

@ -148,6 +148,8 @@ struct SharedContext {
/// If false, the `select` element to have search filtering by crates on rendered docs
/// won't be generated.
pub generate_search_filter: bool,
/// Option disabled by default to generate files used by RLS and some other tools.
pub generate_redirect_pages: bool,
}
impl SharedContext {
@ -516,6 +518,7 @@ pub fn run(mut krate: clean::Crate,
resource_suffix,
static_root_path,
generate_search_filter,
generate_redirect_pages,
..
} = options;
@ -545,6 +548,7 @@ pub fn run(mut krate: clean::Crate,
resource_suffix,
static_root_path,
generate_search_filter,
generate_redirect_pages,
};
// If user passed in `--playground-url` arg, we fill in crate name here
@ -2246,17 +2250,18 @@ impl Context {
if !self.render_redirect_pages {
all.append(full_path(self, &item), &item_type);
}
// Redirect from a sane URL using the namespace to Rustdoc's
// URL for the page.
let redir_name = format!("{}.{}.html", name, item_type.name_space());
let redir_dst = self.dst.join(redir_name);
if let Ok(redirect_out) = OpenOptions::new().create_new(true)
.write(true)
.open(&redir_dst) {
let mut redirect_out = BufWriter::new(redirect_out);
try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst);
if self.shared.generate_redirect_pages {
// Redirect from a sane URL using the namespace to Rustdoc's
// URL for the page.
let redir_name = format!("{}.{}.html", name, item_type.name_space());
let redir_dst = self.dst.join(redir_name);
if let Ok(redirect_out) = OpenOptions::new().create_new(true)
.write(true)
.open(&redir_dst) {
let mut redirect_out = BufWriter::new(redirect_out);
try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst);
}
}
// If the item is a macro, redirect from the old macro URL (with !)
// to the new one (without).
if item_type == ItemType::Macro {