From d4057e8df01a2d1b580952e1be4099347bd5c27a Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 10 Jan 2025 16:45:32 -0600 Subject: [PATCH 1/3] re-add --disable-minification to rustdoc this also makes the rust.docs-minification option work as advertised in config.toml nothing fancy this time, this is intended to be perma-unstable. it's only really here for the benefit of rustdoc devs. mitegates https://github.com/rust-lang/rust/issues/135345 --- src/librustdoc/config.rs | 6 ++++++ src/librustdoc/html/render/write_shared.rs | 10 +++++++++- src/librustdoc/lib.rs | 9 ++++++++- .../rustdoc-default-output/output-default.stdout | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index af3c7cc7be345..80bc6cebd2aa9 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -303,6 +303,8 @@ pub(crate) struct RenderOptions { pub(crate) include_parts_dir: Vec, /// Where to write crate-info pub(crate) parts_out_dir: Option, + /// disable minification of CSS/JS + pub(crate) disable_minification: bool, } #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -781,6 +783,9 @@ impl Options { let unstable_features = rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref()); + + let disable_minification = matches.opt_present("disable-minification"); + let options = Options { bin_crate, proc_macro_crate, @@ -857,6 +862,7 @@ impl Options { should_merge, include_parts_dir, parts_out_dir, + disable_minification, }; Some((input, options, render_options)) } diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index ce10e5ecc2441..fb6f3bc2c76ed 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -207,7 +207,15 @@ fn write_static_files( if opt.emit.is_empty() || opt.emit.contains(&EmitType::Toolchain) { static_files::for_each(|f: &static_files::StaticFile| { let filename = static_dir.join(f.output_filename()); - fs::write(&filename, f.minified()).map_err(|e| PathError::new(e, &filename)) + let contents: &[u8]; + let contents_vec: Vec; + if opt.disable_minification { + contents = f.bytes; + } else { + contents_vec = f.minified(); + contents = &contents_vec; + }; + fs::write(&filename, contents).map_err(|e| PathError::new(e, &filename)) })?; } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 96ca96ee6bc15..330b2507de89b 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -651,8 +651,15 @@ fn opts() -> Vec { "", "add arguments to be used when compiling doctests", ), + opt( + Unstable, + FlagMulti, + "", + "disable-minification", + "diable the minification of CSS/JS files", + "", + ), // deprecated / removed options - opt(Unstable, FlagMulti, "", "disable-minification", "removed", ""), opt( Stable, Multi, diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index c2d9309ba2e6d..adf7ee794fd28 100644 --- a/tests/run-make/rustdoc-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout @@ -194,7 +194,7 @@ Options: --doctest-compilation-args add arguments to be used when compiling doctests --disable-minification - removed + diable the minification of CSS/JS files --plugin-path DIR removed, see issue #44136 for From 244316f711175eb072959d5654454b9e51cf3251 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 14 Jan 2025 08:54:55 -0600 Subject: [PATCH 2/3] add disclaimer to --disable-minification --- src/librustdoc/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 330b2507de89b..e9b2bff089fbd 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -656,7 +656,7 @@ fn opts() -> Vec { FlagMulti, "", "disable-minification", - "diable the minification of CSS/JS files", + "diable the minification of CSS/JS files (perma-unstable, do not use with cached files)", "", ), // deprecated / removed options From f5e23d5c7b36d5c24e0133e0c2218810688e691c Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 14 Jan 2025 09:51:55 -0600 Subject: [PATCH 3/3] fix typo and unit test --- src/librustdoc/lib.rs | 2 +- tests/run-make/rustdoc-default-output/output-default.stdout | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index e9b2bff089fbd..ba620b6cb6bef 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -656,7 +656,7 @@ fn opts() -> Vec { FlagMulti, "", "disable-minification", - "diable the minification of CSS/JS files (perma-unstable, do not use with cached files)", + "disable the minification of CSS/JS files (perma-unstable, do not use with cached files)", "", ), // deprecated / removed options diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index adf7ee794fd28..c1b246e849ce4 100644 --- a/tests/run-make/rustdoc-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout @@ -194,7 +194,8 @@ Options: --doctest-compilation-args add arguments to be used when compiling doctests --disable-minification - diable the minification of CSS/JS files + disable the minification of CSS/JS files + (perma-unstable, do not use with cached files) --plugin-path DIR removed, see issue #44136 for