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:
commit
f8ccdeb0d4
13 changed files with 64 additions and 23 deletions
|
|
@ -192,6 +192,8 @@ pub struct RenderOptions {
|
|||
/// 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 Options {
|
||||
|
|
@ -436,6 +438,7 @@ impl Options {
|
|||
let static_root_path = matches.opt_str("static-root-path");
|
||||
let generate_search_filter = !matches.opt_present("disable-per-crate-search");
|
||||
let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
|
||||
let generate_redirect_pages = matches.opt_present("generate-redirect-pages");
|
||||
|
||||
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
|
||||
|
||||
|
|
@ -480,6 +483,7 @@ impl Options {
|
|||
markdown_css,
|
||||
markdown_playground_url,
|
||||
generate_search_filter,
|
||||
generate_redirect_pages,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -345,6 +345,11 @@ fn opts() -> Vec<RustcOptGroup> {
|
|||
"Directory to persist doctest executables into",
|
||||
"PATH")
|
||||
}),
|
||||
unstable("generate-redirect-pages", |o| {
|
||||
o.optflag("",
|
||||
"generate-redirect-pages",
|
||||
"Generate extra pages to support legacy URLs and tool links")
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue