diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/mdbook/src/book | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/mdbook/src/book')
-rw-r--r-- | vendor/mdbook/src/book/init.rs | 14 | ||||
-rw-r--r-- | vendor/mdbook/src/book/mod.rs | 37 |
2 files changed, 41 insertions, 10 deletions
diff --git a/vendor/mdbook/src/book/init.rs b/vendor/mdbook/src/book/init.rs index dd3fa8b0d..ebcdd9349 100644 --- a/vendor/mdbook/src/book/init.rs +++ b/vendor/mdbook/src/book/init.rs @@ -6,6 +6,7 @@ use super::MDBook; use crate::config::Config; use crate::errors::*; use crate::theme; +use crate::utils::fs::write_file; use log::{debug, error, info, trace}; /// A helper for setting up a new book and its directory structure. @@ -158,6 +159,19 @@ impl BookBuilder { let mut highlight_js = File::create(themedir.join("highlight.js"))?; highlight_js.write_all(theme::HIGHLIGHT_JS)?; + write_file(&themedir.join("fonts"), "fonts.css", theme::fonts::CSS)?; + for (file_name, contents) in theme::fonts::LICENSES { + write_file(&themedir, file_name, contents)?; + } + for (file_name, contents) in theme::fonts::OPEN_SANS.iter() { + write_file(&themedir, file_name, contents)?; + } + write_file( + &themedir, + theme::fonts::SOURCE_CODE_PRO.0, + theme::fonts::SOURCE_CODE_PRO.1, + )?; + Ok(()) } diff --git a/vendor/mdbook/src/book/mod.rs b/vendor/mdbook/src/book/mod.rs index 75bbcc714..33fe93f7f 100644 --- a/vendor/mdbook/src/book/mod.rs +++ b/vendor/mdbook/src/book/mod.rs @@ -196,21 +196,26 @@ impl MDBook { Ok(()) } - /// Run the entire build process for a particular [`Renderer`]. - pub fn execute_build_process(&self, renderer: &dyn Renderer) -> Result<()> { - let mut preprocessed_book = self.book.clone(); + /// Run preprocessors and return the final book. + pub fn preprocess_book(&self, renderer: &dyn Renderer) -> Result<(Book, PreprocessorContext)> { let preprocess_ctx = PreprocessorContext::new( self.root.clone(), self.config.clone(), renderer.name().to_string(), ); - + let mut preprocessed_book = self.book.clone(); for preprocessor in &self.preprocessors { if preprocessor_should_run(&**preprocessor, renderer, &self.config) { debug!("Running the {} preprocessor.", preprocessor.name()); preprocessed_book = preprocessor.run(&preprocess_ctx, preprocessed_book)?; } } + Ok((preprocessed_book, preprocess_ctx)) + } + + /// Run the entire build process for a particular [`Renderer`]. + pub fn execute_build_process(&self, renderer: &dyn Renderer) -> Result<()> { + let (preprocessed_book, preprocess_ctx) = self.preprocess_book(renderer)?; let name = renderer.name(); let build_dir = self.build_dir_for(name); @@ -264,13 +269,25 @@ impl MDBook { let mut chapter_found = false; - // FIXME: Is "test" the proper renderer name to use here? - let preprocess_context = - PreprocessorContext::new(self.root.clone(), self.config.clone(), "test".to_string()); + struct TestRenderer; + impl Renderer for TestRenderer { + // FIXME: Is "test" the proper renderer name to use here? + fn name(&self) -> &str { + "test" + } - let book = LinkPreprocessor::new().run(&preprocess_context, self.book.clone())?; - // Index Preprocessor is disabled so that chapter paths continue to point to the - // actual markdown files. + fn render(&self, _: &RenderContext) -> Result<()> { + Ok(()) + } + } + + // Index Preprocessor is disabled so that chapter paths + // continue to point to the actual markdown files. + self.preprocessors = determine_preprocessors(&self.config)? + .into_iter() + .filter(|pre| pre.name() != IndexPreprocessor::NAME) + .collect(); + let (book, _) = self.preprocess_book(&TestRenderer)?; let mut failed = false; for item in book.iter() { |