Skip to content

Commit 413938d

Browse files
committed
Fix --external-css to be invocation-specific and note main.js should be invocation specific
1 parent 1086d9b commit 413938d

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/librustdoc/html/render/write_shared.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ pub(super) fn write_shared(
213213
let mut themes: Vec<&String> = themes.iter().collect();
214214
themes.sort();
215215

216+
// FIXME: this should probably not be a toolchain file since it depends on `--theme`.
217+
// But it seems a shame to copy it over and over when it's almost always the same.
218+
// Maybe we can change the representation to move this out of main.js?
216219
write_minify(
217220
"main.js",
218221
&static_files::MAIN_JS.replace(
@@ -238,7 +241,13 @@ pub(super) fn write_shared(
238241

239242
if let Some(ref css) = cx.shared.layout.css_file_extension {
240243
let buffer = try_err!(fs::read_to_string(css), css);
241-
write_minify("theme.css", &buffer)?;
244+
// This varies based on the invocation, so it can't go through the write_minify wrapper.
245+
cx.write_minify(
246+
SharedResource::InvocationSpecific { basename: "theme.css" },
247+
&buffer,
248+
options.enable_minification,
249+
&options.emit,
250+
)?;
242251
}
243252
write_minify("normalize.css", static_files::NORMALIZE_CSS)?;
244253
for (name, contents) in &*FILES_UNVERSIONED {

src/test/run-make/emit-shared-files/Makefile

+17-7
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,40 @@ ALL_SHARED = $(TMPDIR)/all-shared
77
all: invocation-only toolchain-only all-shared
88

99
invocation-only:
10-
$(RUSTDOC) -Z unstable-options --emit=invocation-specific --output $(INVOCATION_ONLY) --resource-suffix=-xxx --theme y.css x.rs
10+
$(RUSTDOC) -Z unstable-options --emit=invocation-specific --output $(INVOCATION_ONLY) --resource-suffix=-xxx --theme y.css --extend-css z.css x.rs
1111
[ -e $(INVOCATION_ONLY)/search-index-xxx.js ]
1212
[ -e $(INVOCATION_ONLY)/settings.html ]
1313
[ -e $(INVOCATION_ONLY)/x/all.html ]
1414
[ -e $(INVOCATION_ONLY)/x/index.html ]
15-
# FIXME: this probably shouldn't have a suffix
16-
[ -e $(INVOCATION_ONLY)/y-xxx.css ]
15+
[ -e $(INVOCATION_ONLY)/theme-xxx.css ] # generated from z.css
1716
! [ -e $(INVOCATION_ONLY)/storage-xxx.js ]
1817
! [ -e $(INVOCATION_ONLY)/SourceSerifPro-It.ttf.woff ]
1918

19+
# FIXME: this probably shouldn't have a suffix
20+
[ -e $(INVOCATION_ONLY)/y-xxx.css ]
21+
# FIXME: this is technically incorrect (see `write_shared`)
22+
! [ -e $(INVOCATION_ONLY)/main-xxx.js ]
23+
2024
toolchain-only:
21-
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx x.rs
25+
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx --extend-css z.css x.rs
2226
[ -e $(TOOLCHAIN_ONLY)/storage-xxx.js ]
23-
! [ -e $(TOOLCHAIN_ONLY)/y-xxx.css ]
2427
! [ -e $(TOOLCHAIN_ONLY)/SourceSerifPro-It.ttf.woff ]
2528
! [ -e $(TOOLCHAIN_ONLY)/search-index-xxx.js ]
2629
! [ -e $(TOOLCHAIN_ONLY)/x/index.html ]
30+
! [ -e $(TOOLCHAIN_ONLY)/theme.css ]
31+
32+
[ -e $(TOOLCHAIN_ONLY)/main-xxx.js ]
33+
! [ -e $(TOOLCHAIN_ONLY)/y-xxx.css ]
2734

2835
all-shared:
29-
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx x.rs
36+
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx --extend-css z.css x.rs
3037
[ -e $(ALL_SHARED)/storage-xxx.js ]
3138
[ -e $(ALL_SHARED)/SourceSerifPro-It.ttf.woff ]
32-
! [ -e $(ALL_SHARED)/y-xxx.css ]
3339
! [ -e $(ALL_SHARED)/search-index-xxx.js ]
3440
! [ -e $(ALL_SHARED)/settings.html ]
3541
! [ -e $(ALL_SHARED)/x ]
3642
! [ -e $(ALL_SHARED)/src ]
43+
! [ -e $(ALL_SHARED)/theme.css ]
44+
45+
[ -e $(ALL_SHARED)/main-xxx.js ]
46+
! [ -e $(ALL_SHARED)/y-xxx.css ]

src/test/run-make/emit-shared-files/y.css

Whitespace-only changes.

src/test/run-make/emit-shared-files/z.css

Whitespace-only changes.

0 commit comments

Comments
 (0)