diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs
index 34994097812c2..b2f2283c177df 100644
--- a/src/librustdoc/html/render/write_shared.rs
+++ b/src/librustdoc/html/render/write_shared.rs
@@ -213,6 +213,9 @@ pub(super) fn write_shared(
let mut themes: Vec<&String> = themes.iter().collect();
themes.sort();
+ // FIXME: this should probably not be a toolchain file since it depends on `--theme`.
+ // But it seems a shame to copy it over and over when it's almost always the same.
+ // Maybe we can change the representation to move this out of main.js?
write_minify(
"main.js",
&static_files::MAIN_JS.replace(
@@ -238,7 +241,13 @@ pub(super) fn write_shared(
if let Some(ref css) = cx.shared.layout.css_file_extension {
let buffer = try_err!(fs::read_to_string(css), css);
- write_minify("theme.css", &buffer)?;
+ // This varies based on the invocation, so it can't go through the write_minify wrapper.
+ cx.write_minify(
+ SharedResource::InvocationSpecific { basename: "theme.css" },
+ &buffer,
+ options.enable_minification,
+ &options.emit,
+ )?;
}
write_minify("normalize.css", static_files::NORMALIZE_CSS)?;
for (name, contents) in &*FILES_UNVERSIONED {
diff --git a/src/test/run-make/emit-shared-files/Makefile b/src/test/run-make/emit-shared-files/Makefile
index 66a36dae9d370..5c4825ae66c87 100644
--- a/src/test/run-make/emit-shared-files/Makefile
+++ b/src/test/run-make/emit-shared-files/Makefile
@@ -7,30 +7,40 @@ ALL_SHARED = $(TMPDIR)/all-shared
all: invocation-only toolchain-only all-shared
invocation-only:
- $(RUSTDOC) -Z unstable-options --emit=invocation-specific --output $(INVOCATION_ONLY) --resource-suffix=-xxx --theme y.css x.rs
+ $(RUSTDOC) -Z unstable-options --emit=invocation-specific --output $(INVOCATION_ONLY) --resource-suffix=-xxx --theme y.css --extend-css z.css x.rs
[ -e $(INVOCATION_ONLY)/search-index-xxx.js ]
[ -e $(INVOCATION_ONLY)/settings.html ]
[ -e $(INVOCATION_ONLY)/x/all.html ]
[ -e $(INVOCATION_ONLY)/x/index.html ]
- # FIXME: this probably shouldn't have a suffix
- [ -e $(INVOCATION_ONLY)/y-xxx.css ]
+ [ -e $(INVOCATION_ONLY)/theme-xxx.css ] # generated from z.css
! [ -e $(INVOCATION_ONLY)/storage-xxx.js ]
! [ -e $(INVOCATION_ONLY)/SourceSerifPro-It.ttf.woff ]
+ # FIXME: this probably shouldn't have a suffix
+ [ -e $(INVOCATION_ONLY)/y-xxx.css ]
+ # FIXME: this is technically incorrect (see `write_shared`)
+ ! [ -e $(INVOCATION_ONLY)/main-xxx.js ]
+
toolchain-only:
- $(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx x.rs
+ $(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx --extend-css z.css x.rs
[ -e $(TOOLCHAIN_ONLY)/storage-xxx.js ]
- ! [ -e $(TOOLCHAIN_ONLY)/y-xxx.css ]
! [ -e $(TOOLCHAIN_ONLY)/SourceSerifPro-It.ttf.woff ]
! [ -e $(TOOLCHAIN_ONLY)/search-index-xxx.js ]
! [ -e $(TOOLCHAIN_ONLY)/x/index.html ]
+ ! [ -e $(TOOLCHAIN_ONLY)/theme.css ]
+
+ [ -e $(TOOLCHAIN_ONLY)/main-xxx.js ]
+ ! [ -e $(TOOLCHAIN_ONLY)/y-xxx.css ]
all-shared:
- $(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx x.rs
+ $(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx --extend-css z.css x.rs
[ -e $(ALL_SHARED)/storage-xxx.js ]
[ -e $(ALL_SHARED)/SourceSerifPro-It.ttf.woff ]
- ! [ -e $(ALL_SHARED)/y-xxx.css ]
! [ -e $(ALL_SHARED)/search-index-xxx.js ]
! [ -e $(ALL_SHARED)/settings.html ]
! [ -e $(ALL_SHARED)/x ]
! [ -e $(ALL_SHARED)/src ]
+ ! [ -e $(ALL_SHARED)/theme.css ]
+
+ [ -e $(ALL_SHARED)/main-xxx.js ]
+ ! [ -e $(ALL_SHARED)/y-xxx.css ]
diff --git a/src/test/run-make/emit-shared-files/y.css b/src/test/run-make/emit-shared-files/y.css
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/src/test/run-make/emit-shared-files/z.css b/src/test/run-make/emit-shared-files/z.css
new file mode 100644
index 0000000000000..e69de29bb2d1d