diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-03-07 10:41:18 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-07 10:41:18 +0900 |
| commit | 379679b913410e1bada4e754fde6e2799664fc91 (patch) | |
| tree | 9ffbd765c4a3f0247f28c4006e332e0ea50e3308 /src/librustdoc/html/render | |
| parent | a0dcfdfb7640b0e807e48d8234d41e5a3a0a7e84 (diff) | |
| parent | 173d2aaa009d7d1b76addefc204a2bde329caa83 (diff) | |
| download | rust-379679b913410e1bada4e754fde6e2799664fc91.tar.gz rust-379679b913410e1bada4e754fde6e2799664fc91.zip | |
Rollup merge of #82803 - jyn514:unversioned-files, r=GuillaumeGomez
rustdoc: Add an unstable option to print all unversioned files This allows sharing those files between different doc invocations without having to know their names ahead of time. Helps with https://github.com/rust-lang/docs.rs/issues/1302. r? ````@GuillaumeGomez```` cc ````@pietroalbini```` ````@Nemo157````
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/html/render/write_shared.rs | 39 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 50cae50c2c3..9b9ec2581cf 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -33,6 +33,7 @@ mod print_item; mod write_shared; crate use context::*; +crate use write_shared::FILES_UNVERSIONED; use std::cell::{Cell, RefCell}; use std::collections::VecDeque; diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index cbf0f9a4927..02ad01aa29a 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -3,6 +3,7 @@ use std::fmt::Write; use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, BufReader}; +use std::lazy::SyncLazy as Lazy; use std::path::{Component, Path, PathBuf}; use itertools::Itertools; @@ -18,6 +19,26 @@ use crate::error::Error; use crate::formats::FormatRenderer; use crate::html::{layout, static_files}; +crate 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, + } +}); + pub(super) fn write_shared( cx: &Context<'_>, krate: &Crate, @@ -212,21 +233,9 @@ 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)?; + 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(); |
