From 080a8e7a7137482b91cb4c76326f0d9d1243a6d7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 1 Mar 2019 17:03:15 +0100 Subject: [PATCH 1/4] Prevent cache issues on version updates --- src/bootstrap/doc.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index ae329286486d6..7434d39a44bba 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -343,12 +343,10 @@ fn invoke_rustdoc( .arg("--html-before-content").arg(&version_info) .arg("--html-in-header").arg(&favicon) .arg("--markdown-no-toc") - .arg("--markdown-playground-url") - .arg("https://play.rust-lang.org/") - .arg("-o").arg(&out) - .arg(&path) - .arg("--markdown-css") - .arg("../rust.css"); + .arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM) + .arg("--markdown-playground-url").arg("https://play.rust-lang.org/") + .arg("-o").arg(&out).arg(&path) + .arg("--markdown-css").arg("../rust.css"); builder.run(&mut cmd); } @@ -430,9 +428,9 @@ impl Step for Standalone { .arg("--html-before-content").arg(&version_info) .arg("--html-in-header").arg(&favicon) .arg("--markdown-no-toc") + .arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM) .arg("--index-page").arg(&builder.src.join("src/doc/index.md")) - .arg("--markdown-playground-url") - .arg("https://play.rust-lang.org/") + .arg("--markdown-playground-url").arg("https://play.rust-lang.org/") .arg("-o").arg(&out) .arg(&path); @@ -523,6 +521,7 @@ impl Step for Std { .arg("--markdown-css").arg("rust.css") .arg("--markdown-no-toc") .arg("--generate-redirect-pages") + .arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM) .arg("--index-page").arg(&builder.src.join("src/doc/index.md")); builder.run(&mut cargo); From 2d6745de0e4c6c8f304982e812ce40c50b813d6f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 13 Mar 2019 00:32:13 +0100 Subject: [PATCH 2/4] Add resource suffix for libtest and proc_macro as well --- src/bootstrap/doc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 7434d39a44bba..cab6abf74b6bd 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -343,7 +343,6 @@ fn invoke_rustdoc( .arg("--html-before-content").arg(&version_info) .arg("--html-in-header").arg(&favicon) .arg("--markdown-no-toc") - .arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM) .arg("--markdown-playground-url").arg("https://play.rust-lang.org/") .arg("-o").arg(&out).arg(&path) .arg("--markdown-css").arg("../rust.css"); @@ -428,7 +427,6 @@ impl Step for Standalone { .arg("--html-before-content").arg(&version_info) .arg("--html-in-header").arg(&favicon) .arg("--markdown-no-toc") - .arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM) .arg("--index-page").arg(&builder.src.join("src/doc/index.md")) .arg("--markdown-playground-url").arg("https://play.rust-lang.org/") .arg("-o").arg(&out) @@ -588,6 +586,7 @@ impl Step for Test { cargo.arg("--no-deps") .arg("-p").arg("test") + .env("RUSTDOC_RESOURCE_SUFFIX", crate::channel::CFG_RELEASE_NUM) .env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1"); builder.run(&mut cargo); @@ -659,6 +658,7 @@ impl Step for WhitelistedRustc { // for which docs must be built. for krate in &["proc_macro"] { cargo.arg("-p").arg(krate) + .env("RUSTDOC_RESOURCE_SUFFIX", crate::channel::CFG_RELEASE_NUM) .env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1"); } From 50c50e3a82e80dcc31f366b81c491fd0bf8ed5ac Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 25 Mar 2019 22:01:19 +0100 Subject: [PATCH 3/4] Handle RUSTDOC_RESOURCE_SUFFIX env variable for rustdoc build --- src/bootstrap/bin/rustdoc.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index 085f243785cbe..1c9f6e1ab285c 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -69,6 +69,17 @@ fn main() { .arg("unstable-options"); } cmd.arg("--generate-redirect-pages"); + has_unstable = true; + } + + // Needed to be able to run all rustdoc tests. + if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") { + // This "unstable-options" can be removed when `--resource-suffix` is stabilized + if !has_unstable { + cmd.arg("-Z") + .arg("unstable-options"); + } + cmd.arg("--resource-suffix").arg(x); } if verbose > 1 { From 5652dd677c63d0d1bc7d26f09baceaff7e7525b5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Mar 2019 23:57:16 +0100 Subject: [PATCH 4/4] Fix error index CSS file name --- src/bootstrap/doc.rs | 1 + src/tools/error_index_generator/main.rs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index cab6abf74b6bd..71708a0bdb1cf 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -889,6 +889,7 @@ impl Step for ErrorIndex { ); index.arg("html"); index.arg(out.join("error-index.html")); + index.arg(crate::channel::CFG_RELEASE_NUM); // FIXME: shouldn't have to pass this env var index.env("CFG_BUILD", &builder.config.build) diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index faeeea605a2b4..04986b59ea0f1 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -27,9 +27,10 @@ enum OutputFormat { } impl OutputFormat { - fn from(format: &str) -> OutputFormat { + fn from(format: &str, resource_suffix: &str) -> OutputFormat { match &*format.to_lowercase() { - "html" => OutputFormat::HTML(HTMLFormatter(RefCell::new(IdMap::new()))), + "html" => OutputFormat::HTML(HTMLFormatter(RefCell::new(IdMap::new()), + resource_suffix.to_owned())), "markdown" => OutputFormat::Markdown(MarkdownFormatter), s => OutputFormat::Unknown(s.to_owned()), } @@ -44,7 +45,7 @@ trait Formatter { fn footer(&self, output: &mut dyn Write) -> Result<(), Box>; } -struct HTMLFormatter(RefCell); +struct HTMLFormatter(RefCell, String); struct MarkdownFormatter; impl Formatter for HTMLFormatter { @@ -55,7 +56,7 @@ impl Formatter for HTMLFormatter { Rust Compiler Error Index - + -"##)?; +"##, suffix=self.1)?; Ok(()) } @@ -242,9 +243,12 @@ fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box (OutputFormat, PathBuf) { let mut args = env::args().skip(1); - let format = args.next().map(|a| OutputFormat::from(&a)) - .unwrap_or(OutputFormat::from("html")); - let dst = args.next().map(PathBuf::from).unwrap_or_else(|| { + let format = args.next(); + let dst = args.next(); + let resource_suffix = args.next().unwrap_or_else(String::new); + let format = format.map(|a| OutputFormat::from(&a, &resource_suffix)) + .unwrap_or(OutputFormat::from("html", &resource_suffix)); + let dst = dst.map(PathBuf::from).unwrap_or_else(|| { match format { OutputFormat::HTML(..) => PathBuf::from("doc/error-index.html"), OutputFormat::Markdown(..) => PathBuf::from("doc/error-index.md"),