Description: 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
Forwarded: not-needed
Gbp-Pq: Topic prune
Gbp-Pq: Name d-0002-mdbook-strip-embedded-libs.patch
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 {
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,
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 {
{{/if}}
<!-- Fonts -->
- <link rel="stylesheet" href="{{ resource "fonts/fonts.css" }}">
+ <link rel="stylesheet" href="{{ path_to_root }}css/font-awesome.min.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" id="mdbook-highlight-css" href="{{ resource "highlight.css" }}">
{{#if mathjax_support}}
<!-- MathJax -->
- <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+ <script async src="MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
<!-- Provide site root and default themes to javascript -->
</script>
{{/if}}
- {{#if playground_line_numbers}}
- <script>
- window.playground_line_numbers = true;
- </script>
- {{/if}}
-
- {{#if playground_copyable}}
- <script>
- window.playground_copyable = true;
- </script>
- {{/if}}
-
- {{#if playground_js}}
- <script src="{{ resource "ace.js" }}"></script>
- <script src="{{ resource "mode-rust.js" }}"></script>
- <script src="{{ resource "editor.js" }}"></script>
- <script src="{{ resource "theme-dawn.js" }}"></script>
- <script src="{{ resource "theme-tomorrow_night.js" }}"></script>
- {{/if}}
-
{{#if search_js}}
- <script src="{{ resource "elasticlunr.min.js" }}"></script>
- <script src="{{ resource "mark.min.js" }}"></script>
<script src="{{ resource "searcher.js" }}"></script>
{{/if}}
<link rel="stylesheet" href="{{ resource "css/print.css" }}" media="print">
{{/if}}
<!-- Fonts -->
- <link rel="stylesheet" href="{{ resource "fonts/fonts.css" }}">
+ <link rel="stylesheet" href="{{ path_to_root }}css/font-awesome.min.css">
+ {{#if copy_fonts}}
+ {{/if}}
<!-- Custom theme stylesheets -->
{{#each additional_css}}
<link rel="stylesheet" href="{{ resource this }}">
.as_bytes(),
);
static_files.add_builtin("searcher.js", searcher::JS);
- static_files.add_builtin("mark.min.js", searcher::MARK_JS);
- static_files.add_builtin("elasticlunr.min.js", searcher::ELASTICLUNR_JS);
debug!("Copying search files ✓");
}
//! Support for writing static files.
use super::helpers::resources::ResourceHelper;
-use crate::theme::{self, Theme, playground_editor};
+use crate::theme::{self, Theme};
use anyhow::{Context, Result};
use mdbook_core::config::HtmlConfig;
use mdbook_core::static_regex;
use mdbook_core::utils::fs;
use std::borrow::Cow;
use std::collections::HashMap;
+use std::os::unix::fs::symlink;
use std::path::{Path, PathBuf};
use tracing::debug;
if let Some(contents) = &theme.favicon_svg {
this.add_builtin("favicon.svg", contents);
}
- this.add_builtin("highlight.css", &theme.highlight_css);
this.add_builtin("tomorrow-night.css", &theme.tomorrow_night_css);
this.add_builtin("ayu-highlight.css", &theme.ayu_highlight_css);
- this.add_builtin("highlight.js", &theme.highlight_js);
- this.add_builtin("clipboard.min.js", &theme.clipboard_js);
- if theme.fonts_css.is_none() {
- this.add_builtin("fonts/fonts.css", theme::fonts::CSS);
- for (file_name, contents) in theme::fonts::LICENSES.iter() {
- this.add_builtin(file_name, contents);
- }
- for (file_name, contents) in theme::fonts::OPEN_SANS.iter() {
- this.add_builtin(file_name, contents);
- }
- this.add_builtin(
- theme::fonts::SOURCE_CODE_PRO.0,
- theme::fonts::SOURCE_CODE_PRO.1,
- );
- } else if let Some(fonts_css) = &theme.fonts_css {
- if !fonts_css.is_empty() {
- this.add_builtin("fonts/fonts.css", fonts_css);
- }
- }
-
- 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
- this.add_builtin("editor.js", playground_editor::JS);
- this.add_builtin("ace.js", playground_editor::ACE_JS);
- this.add_builtin("mode-rust.js", playground_editor::MODE_RUST_JS);
- this.add_builtin("theme-dawn.js", playground_editor::THEME_DAWN_JS);
- this.add_builtin(
- "theme-tomorrow_night.js",
- playground_editor::THEME_TOMORROW_NIGHT_JS,
- );
- }
let custom_files = html_config
.additional_css
}
}
}
+ symlink(
+ "/usr/share/javascript/highlight.js/styles/atelier-dune-light.css",
+ destination.join("highlight.css"),
+ )?;
+ symlink(
+ "/usr/share/fonts-font-awesome/css/font-awesome.min.css",
+ destination.join("css/font-awesome.min.css"),
+ )?;
+ symlink(
+ "/usr/share/fonts-font-awesome/fonts",
+ destination.join("fonts"),
+ )?;
+
+ symlink(
+ "/usr/share/javascript/mathjax/MathJax.js",
+ destination.join("MathJax.js"),
+ )?;
let hash_map = self.hash_map;
Ok(ResourceHelper { hash_map })
}
use std::path::{Path, PathBuf};
use tracing::{info, warn};
-pub(crate) mod fonts;
-pub(crate) mod playground_editor;
#[cfg(feature = "search")]
pub(crate) mod searcher;
static FAVICON_PNG: &[u8] = include_bytes!("../../front-end/images/favicon.png");
static FAVICON_SVG: &[u8] = include_bytes!("../../front-end/images/favicon.svg");
static JS: &[u8] = include_bytes!("../../front-end/js/book.js");
-static HIGHLIGHT_JS: &[u8] = include_bytes!("../../front-end/js/highlight.js");
static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/tomorrow-night.css");
-static HIGHLIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/highlight.css");
static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/ayu-highlight.css");
-static CLIPBOARD_JS: &[u8] = include_bytes!("../../front-end/js/clipboard.min.js");
/// The `Theme` struct should be used instead of the static variables because
/// the `new()` method will look if the user has a theme directory in their
pub(crate) favicon_png: Option<Vec<u8>>,
pub(crate) favicon_svg: Option<Vec<u8>>,
pub(crate) js: Vec<u8>,
- pub(crate) highlight_css: Vec<u8>,
pub(crate) tomorrow_night_css: Vec<u8>,
pub(crate) ayu_highlight_css: Vec<u8>,
- pub(crate) highlight_js: Vec<u8>,
- pub(crate) clipboard_js: Vec<u8>,
}
impl Theme {
theme_dir.join("css/variables.css"),
&mut theme.variables_css,
),
- (theme_dir.join("highlight.js"), &mut theme.highlight_js),
- (theme_dir.join("clipboard.min.js"), &mut theme.clipboard_js),
- (theme_dir.join("highlight.css"), &mut theme.highlight_css),
(
theme_dir.join("tomorrow-night.css"),
&mut theme.tomorrow_night_css,
fs::write(themedir.join("book.js"), JS)?;
fs::write(themedir.join("favicon.png"), FAVICON_PNG)?;
fs::write(themedir.join("favicon.svg"), FAVICON_SVG)?;
- fs::write(themedir.join("highlight.css"), HIGHLIGHT_CSS)?;
- fs::write(themedir.join("highlight.js"), HIGHLIGHT_JS)?;
fs::write(themedir.join("index.hbs"), INDEX)?;
let cssdir = themedir.join("css");
fs::write(cssdir.join("print.css"), PRINT_CSS)?;
}
- fs::write(themedir.join("fonts").join("fonts.css"), fonts::CSS)?;
- for (file_name, contents) in fonts::LICENSES {
- fs::write(themedir.join(file_name), contents)?;
- }
- for (file_name, contents) in fonts::OPEN_SANS.iter() {
- fs::write(themedir.join(file_name), contents)?;
- }
- fs::write(
- themedir.join(fonts::SOURCE_CODE_PRO.0),
- fonts::SOURCE_CODE_PRO.1,
- )?;
Ok(())
}
}
favicon_png: Some(FAVICON_PNG.to_owned()),
favicon_svg: Some(FAVICON_SVG.to_owned()),
js: JS.to_owned(),
- highlight_css: HIGHLIGHT_CSS.to_owned(),
tomorrow_night_css: TOMORROW_NIGHT_CSS.to_owned(),
ayu_highlight_css: AYU_HIGHLIGHT_CSS.to_owned(),
- highlight_js: HIGHLIGHT_JS.to_owned(),
- clipboard_js: CLIPBOARD_JS.to_owned(),
}
}
}
"css/variables.css",
"fonts/fonts.css",
"book.js",
- "highlight.js",
"tomorrow-night.css",
- "highlight.css",
"ayu-highlight.css",
- "clipboard.min.js",
];
let temp = TempFileBuilder::new().prefix("mdbook-").tempdir().unwrap();
favicon_png: Some(Vec::new()),
favicon_svg: Some(Vec::new()),
js: Vec::new(),
- highlight_css: Vec::new(),
tomorrow_night_css: Vec::new(),
ayu_highlight_css: Vec::new(),
- highlight_js: Vec::new(),
- clipboard_js: Vec::new(),
};
assert_eq!(got, empty);
//! the "search" cargo feature is disabled.
pub(crate) static JS: &[u8] = include_bytes!("../../front-end/searcher/searcher.js");
-pub(crate) static MARK_JS: &[u8] = include_bytes!("../../front-end/searcher/mark.min.js");
-pub(crate) static ELASTICLUNR_JS: &[u8] =
- include_bytes!("../../front-end/searcher/elasticlunr.min.js");