diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-03-05 10:35:22 -0500 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-03-05 10:55:15 -0500 |
| commit | 69a879f3d199580dde491bb679df319867a44e56 (patch) | |
| tree | 6b7cdfc47c69e36128f01f57577c8a3b1a184322 /src/librustdoc/html/render | |
| parent | 8ccc89bc312caa65ca46b55b47492abdd5b6910a (diff) | |
| download | rust-69a879f3d199580dde491bb679df319867a44e56.tar.gz rust-69a879f3d199580dde491bb679df319867a44e56.zip | |
Store `UNVERSIONED_FILES` in a data structure
This allows querying it programatically.
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/write_shared.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index cbf0f9a4927..7fcfe35f9a9 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -4,6 +4,7 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, BufReader}; use std::path::{Component, Path, PathBuf}; +use std::lazy::SyncLazy as Lazy; use itertools::Itertools; use rustc_data_structures::flock; @@ -212,21 +213,26 @@ themePicker.onblur = handleThemeButtonsBlur; static_files::NORMALIZE_CSS, options.enable_minification, )?; - write(cx.dst.join("FiraSans-Regular.woff2"), static_files::fira_sans::REGULAR2)?; - write(cx.dst.join("FiraSans-Medium.woff2"), static_files::fira_sans::MEDIUM2)?; - write(cx.dst.join("FiraSans-Regular.woff"), static_files::fira_sans::REGULAR)?; - write(cx.dst.join("FiraSans-Medium.woff"), static_files::fira_sans::MEDIUM)?; - write(cx.dst.join("FiraSans-LICENSE.txt"), static_files::fira_sans::LICENSE)?; - write(cx.dst.join("SourceSerifPro-Regular.ttf.woff"), static_files::source_serif_pro::REGULAR)?; - write(cx.dst.join("SourceSerifPro-Bold.ttf.woff"), static_files::source_serif_pro::BOLD)?; - write(cx.dst.join("SourceSerifPro-It.ttf.woff"), static_files::source_serif_pro::ITALIC)?; - write(cx.dst.join("SourceSerifPro-LICENSE.md"), static_files::source_serif_pro::LICENSE)?; - write(cx.dst.join("SourceCodePro-Regular.woff"), static_files::source_code_pro::REGULAR)?; - write(cx.dst.join("SourceCodePro-Semibold.woff"), static_files::source_code_pro::SEMIBOLD)?; - write(cx.dst.join("SourceCodePro-LICENSE.txt"), static_files::source_code_pro::LICENSE)?; - write(cx.dst.join("LICENSE-MIT.txt"), static_files::LICENSE_MIT)?; - write(cx.dst.join("LICENSE-APACHE.txt"), static_files::LICENSE_APACHE)?; - write(cx.dst.join("COPYRIGHT.txt"), static_files::COPYRIGHT)?; + static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| map! { + "FiraSans-Regular.woff2" => static_files::fira_sans::REGULAR2, + "FiraSans-Medium.woff2" => static_files::fira_sans::MEDIUM2, + "FiraSans-Regular.woff" => static_files::fira_sans::REGULAR, + "FiraSans-Medium.woff" => static_files::fira_sans::MEDIUM, + "FiraSans-LICENSE.txt" => static_files::fira_sans::LICENSE, + "SourceSerifPro-Regular.ttf.woff" => static_files::source_serif_pro::REGULAR, + "SourceSerifPro-Bold.ttf.woff" => static_files::source_serif_pro::BOLD, + "SourceSerifPro-It.ttf.woff" => static_files::source_serif_pro::ITALIC, + "SourceSerifPro-LICENSE.md" => static_files::source_serif_pro::LICENSE, + "SourceCodePro-Regular.woff" => static_files::source_code_pro::REGULAR, + "SourceCodePro-Semibold.woff" => static_files::source_code_pro::SEMIBOLD, + "SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE, + "LICENSE-MIT.txt" => static_files::LICENSE_MIT, + "LICENSE-APACHE.txt" => static_files::LICENSE_APACHE, + "COPYRIGHT.txt" => static_files::COPYRIGHT, + }); + for (file, contents) in &*FILES_UNVERSIONED { + write(cx.dst.join(file), contents)?; + } fn collect(path: &Path, krate: &str, key: &str) -> io::Result<(Vec<String>, Vec<String>)> { let mut ret = Vec::new(); |
