From f0683f98fa114cc4f9e795031f44be3eebb65790 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 23 Nov 2021 19:22:29 -0800 Subject: Move themes and version into rustdoc-vars We had been injecting the list of themes and the rustdoc version into main.js by rewriting it at doc generation time. By avoiding this rewrite, we can make it easier to edit main.js without regenerating all the docs. Added a more convenient accessor for rustdoc-vars. Changed storage.js to not rely on resourcesSuffix. It could in theory use rustdoc-vars, but because rustdoc-vars is at the end of the HTML, it's not available when storage.js runs (very early in page load). --- src/librustdoc/html/render/write_shared.rs | 34 ++---------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'src/librustdoc/html/render') diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 6b0f8dad4c5..cbb57558636 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -265,26 +265,7 @@ 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( - "/* INSERT THEMES HERE */", - &format!(" = {}", serde_json::to_string(&themes).unwrap()), - ) - .replace( - "/* INSERT RUSTDOC_VERSION HERE */", - &format!( - "rustdoc {}", - rustc_interface::util::version_str().unwrap_or("unknown version") - ), - ), - cx, - options, - )?; + write_minify("main.js", static_files::MAIN_JS, cx, options)?; write_minify("search.js", static_files::SEARCH_JS, cx, options)?; write_minify("settings.js", static_files::SETTINGS_JS, cx, options)?; @@ -292,18 +273,7 @@ pub(super) fn write_shared( write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT, cx, options)?; } - { - write_minify( - "storage.js", - format!( - "var resourcesSuffix = \"{}\";{}", - cx.shared.resource_suffix, - static_files::STORAGE_JS - ), - cx, - options, - )?; - } + write_minify("storage.js", static_files::STORAGE_JS, cx, options)?; if cx.shared.layout.scrape_examples_extension { cx.write_minify( -- cgit 1.4.1-3-g733a5