From fdb3e820b158d8326523555080467c37cd019fa7 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 12 Mar 2021 11:41:46 -0700 Subject: [PATCH 1/2] Add a `disable-minification` option for rustdoc This way, you can debug rustdoc's JavaScript and CSS file with normal F12 Dev Tools and you'll have useful line numbers to work with. --- config.toml.example | 5 +++++ src/bootstrap/config.rs | 3 +++ src/bootstrap/doc.rs | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/config.toml.example b/config.toml.example index 5c4392acca595..ee06e1bd0ba1b 100644 --- a/config.toml.example +++ b/config.toml.example @@ -208,6 +208,11 @@ changelog-seen = 2 # documentation. #docs = true +# Flag to specify whether CSS, JavaScript, and HTML are minified when +# docs are generated. JSON is always minified, because it's enormous, +# and generated in already-minified form from the beginning. +#docs-minification = true + # Indicate whether the compiler should be documented in addition to the standard # library and facade crates. #compiler-docs = false diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index b2af8e59b7c9f..dd2bb78aab72e 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -51,6 +51,7 @@ pub struct Config { pub submodules: bool, pub fast_submodules: bool, pub compiler_docs: bool, + pub docs_minification: bool, pub docs: bool, pub locked_deps: bool, pub vendor: bool, @@ -362,6 +363,7 @@ struct Build { rustfmt: Option, docs: Option, compiler_docs: Option, + docs_minification: Option, submodules: Option, fast_submodules: Option, gdb: Option, @@ -663,6 +665,7 @@ impl Config { config.python = build.python.map(PathBuf::from); set(&mut config.low_priority, build.low_priority); set(&mut config.compiler_docs, build.compiler_docs); + set(&mut config.docs_minification, build.docs_minification); set(&mut config.docs, build.docs); set(&mut config.submodules, build.submodules); set(&mut config.fast_submodules, build.fast_submodules); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 30d690c970507..1168d54b55e58 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -270,6 +270,10 @@ fn invoke_rustdoc( .arg("--markdown-css") .arg("../rust.css"); + if !builder.config.docs_minification { + cmd.arg("-Z").arg("unstable-options").arg("--disable-minification"); + } + builder.run(&mut cmd); } @@ -365,6 +369,10 @@ impl Step for Standalone { .arg(&out) .arg(&path); + if !builder.config.docs_minification { + cmd.arg("--disable-minification"); + } + if filename == "not_found.md" { cmd.arg("--markdown-css").arg("https://doc.rust-lang.org/rust.css"); } else { @@ -437,6 +445,10 @@ impl Step for Std { .arg("--index-page") .arg(&builder.src.join("src/doc/index.md")); + if !builder.config.docs_minification { + cargo.arg("--disable-minification"); + } + builder.run(&mut cargo.into()); }; // Only build the following crates. While we could just iterate over the From 095b6d2037c26f59d27382d627f2d62ac859ca49 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 12 Mar 2021 15:03:54 -0700 Subject: [PATCH 2/2] Make docs-minification default to true --- src/bootstrap/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index dd2bb78aab72e..b9b090bb2d2de 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -559,6 +559,7 @@ impl Config { config.submodules = true; config.fast_submodules = true; config.docs = true; + config.docs_minification = true; config.rust_rpath = true; config.channel = "dev".to_string(); config.codegen_tests = true;