From: Debian Rust Maintainers Date: Sat, 2 Oct 2021 01:08:00 +0100 Subject: d-0002-mdbook-strip-embedded-libs Comment: Use https://github.com/infinity0/mdBook/tree/debian to help you rebase the patch on top of a newer version. . Make sure the paths here match the ones in debian/rust-doc.links --- src/tools/linkchecker/main.rs | 28 +++++- vendor/mdbook/src/book/init.rs | 19 ---- .../src/renderer/html_handlebars/hbs_renderer.rs | 110 ++++----------------- .../mdbook/src/renderer/html_handlebars/search.rs | 2 - vendor/mdbook/src/theme/index.hbs | 99 +------------------ vendor/mdbook/src/theme/mod.rs | 27 ----- vendor/mdbook/src/theme/searcher/mod.rs | 2 - 7 files changed, 47 insertions(+), 240 deletions(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 4170c32..d7dcda7 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -159,7 +159,17 @@ impl Checker { for entry in t!(dir.read_dir()).map(|e| t!(e)) { let path = entry.path(); // Goes through symlinks - let metadata = t!(fs::metadata(&path)); + let metadata = fs::metadata(&path); + if let Err(err) = metadata { + if let Ok(target) = fs::read_link(&path) { + if target.starts_with("/usr/share") { + // broken symlink to /usr/share, ok for our Debian build + return; + } + } + panic!("error at file {:?} while walking - {:?}", path, err) + } + let metadata = t!(metadata); if metadata.is_dir() { self.walk(&path, report); } else { @@ -172,7 +182,15 @@ impl Checker { fn check(&mut self, file: &Path, report: &mut Report) { let (pretty_path, entry) = self.load_file(file, report); let source = match entry { - FileEntry::Missing => panic!("missing file {:?} while walking", file), + FileEntry::Missing => { + if let Ok(target) = fs::read_link(&file) { + if target.starts_with("/usr/share") { + // broken symlink to /usr/share, ok for our Debian build + return; + } + } + panic!("missing file {:?} while walking", file) + } FileEntry::Dir => unreachable!("never with `check` path"), FileEntry::OtherFile => return, FileEntry::Redirect { .. } => return, @@ -238,6 +256,12 @@ impl Checker { let (target_pretty_path, target_entry) = self.load_file(&path, report); let (target_source, target_ids) = match target_entry { FileEntry::Missing => { + if let Ok(target) = fs::read_link(&path) { + if target.starts_with("/usr/share") { + // broken symlink to /usr/share, ok for our Debian build + return; + } + } if is_exception(file, &target_pretty_path) { report.links_ignored_exception += 1; } else { diff --git a/vendor/mdbook/src/book/init.rs b/vendor/mdbook/src/book/init.rs index ebcdd93..41dab42 100644 --- a/vendor/mdbook/src/book/init.rs +++ b/vendor/mdbook/src/book/init.rs @@ -153,25 +153,6 @@ impl BookBuilder { let mut js = File::create(themedir.join("book.js"))?; js.write_all(theme::JS)?; - let mut highlight_css = File::create(themedir.join("highlight.css"))?; - highlight_css.write_all(theme::HIGHLIGHT_CSS)?; - - 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/renderer/html_handlebars/hbs_renderer.rs b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs index e170e2f..caa2eff 100644 --- a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs +++ b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs @@ -3,13 +3,14 @@ use crate::config::{BookConfig, Config, HtmlConfig, Playground, RustEdition}; use crate::errors::*; use crate::renderer::html_handlebars::helpers; use crate::renderer::{RenderContext, Renderer}; -use crate::theme::{self, playground_editor, Theme}; +use crate::theme::{self, Theme}; use crate::utils; use std::borrow::Cow; use std::collections::BTreeMap; use std::collections::HashMap; use std::fs::{self, File}; +use std::os::unix::fs::symlink; use std::path::{Path, PathBuf}; use crate::utils::fs::get_404_output_file; @@ -235,105 +236,28 @@ impl HtmlHandlebars { if let Some(contents) = &theme.favicon_svg { write_file(destination, "favicon.svg", contents)?; } - write_file(destination, "highlight.css", &theme.highlight_css)?; write_file(destination, "tomorrow-night.css", &theme.tomorrow_night_css)?; write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; - write_file(destination, "highlight.js", &theme.highlight_js)?; - write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; - write_file( - destination, - "FontAwesome/css/font-awesome.css", - theme::FONT_AWESOME, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.eot", - theme::FONT_AWESOME_EOT, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.svg", - theme::FONT_AWESOME_SVG, + symlink( + "/usr/share/fonts-font-awesome/css/font-awesome.min.css", + destination.join("css/font-awesome.min.css"), )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.ttf", - theme::FONT_AWESOME_TTF, + symlink( + "/usr/share/fonts-font-awesome/fonts", + destination.join("fonts"), )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.woff", - theme::FONT_AWESOME_WOFF, + symlink( + "/usr/share/javascript/highlight.js/styles/atelier-dune-light.css", + destination.join("highlight.css"), )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.woff2", - theme::FONT_AWESOME_WOFF2, + symlink( + "/usr/share/javascript/highlight.js/highlight.js", + destination.join("highlight.js"), )?; - write_file( - destination, - "FontAwesome/fonts/FontAwesome.ttf", - theme::FONT_AWESOME_TTF, + symlink( + "/usr/share/javascript/mathjax/MathJax.js", + destination.join("MathJax.js"), )?; - if html_config.copy_fonts { - write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?; - for (file_name, contents) in theme::fonts::LICENSES.iter() { - write_file(destination, file_name, contents)?; - } - for (file_name, contents) in theme::fonts::OPEN_SANS.iter() { - write_file(destination, file_name, contents)?; - } - write_file( - destination, - theme::fonts::SOURCE_CODE_PRO.0, - theme::fonts::SOURCE_CODE_PRO.1, - )?; - } - if let Some(fonts_css) = &theme.fonts_css { - if !fonts_css.is_empty() { - if html_config.copy_fonts { - warn!( - "output.html.copy_fonts is deprecated.\n\ - Set copy_fonts=false and ensure the fonts you want are in \ - the `theme/fonts/` directory." - ); - } - write_file(destination, "fonts/fonts.css", &fonts_css)?; - } - } - if !html_config.copy_fonts && theme.fonts_css.is_none() { - warn!( - "output.html.copy_fonts is deprecated.\n\ - This book appears to have copy_fonts=false without a fonts.css file.\n\ - Add an empty `theme/fonts/fonts.css` file to squelch this warning." - ); - } - for font_file in &theme.font_files { - let contents = fs::read(font_file)?; - let filename = font_file.file_name().unwrap(); - let filename = Path::new("fonts").join(filename); - write_file(destination, filename, &contents)?; - } - - let playground_config = &html_config.playground; - - // Ace is a very large dependency, so only load it when requested - if playground_config.editable && playground_config.copy_js { - // Load the editor - write_file(destination, "editor.js", playground_editor::JS)?; - write_file(destination, "ace.js", playground_editor::ACE_JS)?; - write_file(destination, "mode-rust.js", playground_editor::MODE_RUST_JS)?; - write_file( - destination, - "theme-dawn.js", - playground_editor::THEME_DAWN_JS, - )?; - write_file( - destination, - "theme-tomorrow_night.js", - playground_editor::THEME_TOMORROW_NIGHT_JS, - )?; - } Ok(()) } diff --git a/vendor/mdbook/src/renderer/html_handlebars/search.rs b/vendor/mdbook/src/renderer/html_handlebars/search.rs index a9e2f5c..3e3f69c 100644 --- a/vendor/mdbook/src/renderer/html_handlebars/search.rs +++ b/vendor/mdbook/src/renderer/html_handlebars/search.rs @@ -53,8 +53,6 @@ pub fn create_files(search_config: &Search, destination: &Path, book: &Book) -> format!("Object.assign(window.search, {});", index).as_bytes(), )?; utils::fs::write_file(destination, "searcher.js", searcher::JS)?; - utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?; - utils::fs::write_file(destination, "elasticlunr.min.js", searcher::ELASTICLUNR_JS)?; debug!("Copying search files ✓"); } diff --git a/vendor/mdbook/src/theme/index.hbs b/vendor/mdbook/src/theme/index.hbs index 6f3948c..7e5c54c 100644 --- a/vendor/mdbook/src/theme/index.hbs +++ b/vendor/mdbook/src/theme/index.hbs @@ -33,10 +33,7 @@ {{/if}} - - {{#if copy_fonts}} - - {{/if}} + @@ -50,7 +47,7 @@ {{#if mathjax_support}} - + {{/if}} @@ -61,48 +58,6 @@ var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; - - - - - - - - -