summaryrefslogtreecommitdiffstats
path: root/vendor/mdbook/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/mdbook/src
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/mdbook/src')
-rw-r--r--vendor/mdbook/src/cmd/watch.rs73
-rw-r--r--vendor/mdbook/src/config.rs108
-rw-r--r--vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs12
-rw-r--r--vendor/mdbook/src/theme/book.js49
-rw-r--r--vendor/mdbook/src/theme/css/chrome.css137
-rw-r--r--vendor/mdbook/src/theme/css/general.css51
-rw-r--r--vendor/mdbook/src/theme/css/print.css10
-rw-r--r--vendor/mdbook/src/theme/css/variables.css24
-rw-r--r--vendor/mdbook/src/theme/index.hbs35
-rw-r--r--vendor/mdbook/src/utils/fs.rs58
10 files changed, 460 insertions, 97 deletions
diff --git a/vendor/mdbook/src/cmd/watch.rs b/vendor/mdbook/src/cmd/watch.rs
index e9806e1cd..80b9ff1b1 100644
--- a/vendor/mdbook/src/cmd/watch.rs
+++ b/vendor/mdbook/src/cmd/watch.rs
@@ -4,6 +4,7 @@ use ignore::gitignore::Gitignore;
use mdbook::errors::Result;
use mdbook::utils;
use mdbook::MDBook;
+use pathdiff::diff_paths;
use std::path::{Path, PathBuf};
use std::sync::mpsc::channel;
use std::thread::sleep;
@@ -86,12 +87,21 @@ fn find_gitignore(book_root: &Path) -> Option<PathBuf> {
.find(|p| p.exists())
}
+// Note: The usage of `canonicalize` may encounter occasional failures on the Windows platform, presenting a potential risk.
+// For more details, refer to [Pull Request #2229](https://github.com/rust-lang/mdBook/pull/2229#discussion_r1408665981).
fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec<PathBuf> {
+ let ignore_root = ignore
+ .path()
+ .canonicalize()
+ .expect("ignore root canonicalize error");
+
paths
.iter()
.filter(|path| {
+ let relative_path =
+ diff_paths(&path, &ignore_root).expect("One of the paths should be an absolute");
!ignore
- .matched_path_or_any_parents(path, path.is_dir())
+ .matched_path_or_any_parents(&relative_path, relative_path.is_dir())
.is_ignore()
})
.map(|path| path.to_path_buf())
@@ -108,8 +118,7 @@ where
// Create a channel to receive the events.
let (tx, rx) = channel();
- let mut debouncer = match notify_debouncer_mini::new_debouncer(Duration::from_secs(1), None, tx)
- {
+ let mut debouncer = match notify_debouncer_mini::new_debouncer(Duration::from_secs(1), tx) {
Ok(d) => d,
Err(e) => {
error!("Error while trying to watch the files:\n\n\t{:?}", e);
@@ -130,11 +139,16 @@ where
let _ = watcher.watch(&book.root.join("book.toml"), NonRecursive);
for dir in &book.config.build.extra_watch_dirs {
- let path = dir.canonicalize().unwrap();
- if let Err(e) = watcher.watch(&path, Recursive) {
+ let path = book.root.join(dir);
+ let canonical_path = path.canonicalize().unwrap_or_else(|e| {
+ error!("Error while watching extra directory {path:?}:\n {e}");
+ std::process::exit(1);
+ });
+
+ if let Err(e) = watcher.watch(&canonical_path, Recursive) {
error!(
"Error while watching extra directory {:?}:\n {:?}",
- path, e
+ canonical_path, e
);
std::process::exit(1);
}
@@ -152,10 +166,8 @@ where
let paths: Vec<_> = all_events
.filter_map(|event| match event {
Ok(events) => Some(events),
- Err(errors) => {
- for error in errors {
- log::warn!("error while watching for changes: {error}");
- }
+ Err(error) => {
+ log::warn!("error while watching for changes: {error}");
None
}
})
@@ -174,3 +186,44 @@ where
}
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use ignore::gitignore::GitignoreBuilder;
+ use std::env;
+
+ #[test]
+ fn test_filter_ignored_files() {
+ let current_dir = env::current_dir().unwrap();
+
+ let ignore = GitignoreBuilder::new(&current_dir)
+ .add_line(None, "*.html")
+ .unwrap()
+ .build()
+ .unwrap();
+ let should_remain = current_dir.join("record.text");
+ let should_filter = current_dir.join("index.html");
+
+ let remain = filter_ignored_files(ignore, &[should_remain.clone(), should_filter]);
+ assert_eq!(remain, vec![should_remain])
+ }
+
+ #[test]
+ fn filter_ignored_files_should_handle_parent_dir() {
+ let current_dir = env::current_dir().unwrap();
+
+ let ignore = GitignoreBuilder::new(&current_dir)
+ .add_line(None, "*.html")
+ .unwrap()
+ .build()
+ .unwrap();
+
+ let parent_dir = current_dir.join("..");
+ let should_remain = parent_dir.join("record.text");
+ let should_filter = parent_dir.join("index.html");
+
+ let remain = filter_ignored_files(ignore, &[should_remain.clone(), should_filter]);
+ assert_eq!(remain, vec![should_remain])
+ }
+}
diff --git a/vendor/mdbook/src/config.rs b/vendor/mdbook/src/config.rs
index 4641d1a26..7f56e797a 100644
--- a/vendor/mdbook/src/config.rs
+++ b/vendor/mdbook/src/config.rs
@@ -411,6 +411,9 @@ pub struct BookConfig {
pub multilingual: bool,
/// The main language of the book.
pub language: Option<String>,
+ /// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL).
+ /// When not specified, the text direction is derived from [`BookConfig::language`].
+ pub text_direction: Option<TextDirection>,
}
impl Default for BookConfig {
@@ -422,6 +425,43 @@ impl Default for BookConfig {
src: PathBuf::from("src"),
multilingual: false,
language: Some(String::from("en")),
+ text_direction: None,
+ }
+ }
+}
+
+impl BookConfig {
+ /// Gets the realized text direction, either from [`BookConfig::text_direction`]
+ /// or derived from [`BookConfig::language`], to be used by templating engines.
+ pub fn realized_text_direction(&self) -> TextDirection {
+ if let Some(direction) = self.text_direction {
+ direction
+ } else {
+ TextDirection::from_lang_code(self.language.as_deref().unwrap_or_default())
+ }
+ }
+}
+
+/// Text direction to use for HTML output
+#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
+pub enum TextDirection {
+ /// Left to right.
+ #[serde(rename = "ltr")]
+ LeftToRight,
+ /// Right to left
+ #[serde(rename = "rtl")]
+ RightToLeft,
+}
+
+impl TextDirection {
+ /// Gets the text direction from language code
+ pub fn from_lang_code(code: &str) -> Self {
+ match code {
+ // list sourced from here: https://github.com/abarrak/rtl/blob/master/lib/rtl/core.rb#L16
+ "ar" | "ara" | "arc" | "ae" | "ave" | "egy" | "he" | "heb" | "nqo" | "pal" | "phn"
+ | "sam" | "syc" | "syr" | "fa" | "per" | "fas" | "ku" | "kur" | "ur" | "urd"
+ | "pus" | "ps" | "yi" | "yid" => TextDirection::RightToLeft,
+ _ => TextDirection::LeftToRight,
}
}
}
@@ -788,6 +828,7 @@ mod tests {
multilingual: true,
src: PathBuf::from("source"),
language: Some(String::from("ja")),
+ text_direction: None,
};
let build_should_be = BuildConfig {
build_dir: PathBuf::from("outputs"),
@@ -1141,6 +1182,73 @@ mod tests {
}
#[test]
+ fn text_direction_ltr() {
+ let src = r#"
+ [book]
+ text-direction = "ltr"
+ "#;
+
+ let got = Config::from_str(src).unwrap();
+ assert_eq!(got.book.text_direction, Some(TextDirection::LeftToRight));
+ }
+
+ #[test]
+ fn text_direction_rtl() {
+ let src = r#"
+ [book]
+ text-direction = "rtl"
+ "#;
+
+ let got = Config::from_str(src).unwrap();
+ assert_eq!(got.book.text_direction, Some(TextDirection::RightToLeft));
+ }
+
+ #[test]
+ fn text_direction_none() {
+ let src = r#"
+ [book]
+ "#;
+
+ let got = Config::from_str(src).unwrap();
+ assert_eq!(got.book.text_direction, None);
+ }
+
+ #[test]
+ fn test_text_direction() {
+ let mut cfg = BookConfig::default();
+
+ // test deriving the text direction from language codes
+ cfg.language = Some("ar".into());
+ assert_eq!(cfg.realized_text_direction(), TextDirection::RightToLeft);
+
+ cfg.language = Some("he".into());
+ assert_eq!(cfg.realized_text_direction(), TextDirection::RightToLeft);
+
+ cfg.language = Some("en".into());
+ assert_eq!(cfg.realized_text_direction(), TextDirection::LeftToRight);
+
+ cfg.language = Some("ja".into());
+ assert_eq!(cfg.realized_text_direction(), TextDirection::LeftToRight);
+
+ // test forced direction
+ cfg.language = Some("ar".into());
+ cfg.text_direction = Some(TextDirection::LeftToRight);
+ assert_eq!(cfg.realized_text_direction(), TextDirection::LeftToRight);
+
+ cfg.language = Some("ar".into());
+ cfg.text_direction = Some(TextDirection::RightToLeft);
+ assert_eq!(cfg.realized_text_direction(), TextDirection::RightToLeft);
+
+ cfg.language = Some("en".into());
+ cfg.text_direction = Some(TextDirection::LeftToRight);
+ assert_eq!(cfg.realized_text_direction(), TextDirection::LeftToRight);
+
+ cfg.language = Some("en".into());
+ cfg.text_direction = Some(TextDirection::RightToLeft);
+ assert_eq!(cfg.realized_text_direction(), TextDirection::RightToLeft);
+ }
+
+ #[test]
#[should_panic(expected = "Invalid configuration file")]
fn invalid_language_type_error() {
let src = r#"
diff --git a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
index 709aa0667..8ea2f49ef 100644
--- a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
+++ b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
@@ -649,6 +649,10 @@ fn make_data(
json!(config.book.language.clone().unwrap_or_default()),
);
data.insert(
+ "text_direction".to_owned(),
+ json!(config.book.realized_text_direction()),
+ );
+ data.insert(
"book_title".to_owned(),
json!(config.book.title.clone().unwrap_or_default()),
);
@@ -1088,6 +1092,8 @@ struct RenderItemContext<'a> {
#[cfg(test)]
mod tests {
+ use crate::config::TextDirection;
+
use super::*;
use pretty_assertions::assert_eq;
@@ -1299,4 +1305,10 @@ mod tests {
assert_eq!(&*got, *should_be);
}
}
+
+ #[test]
+ fn test_json_direction() {
+ assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
+ assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
+ }
}
diff --git a/vendor/mdbook/src/theme/book.js b/vendor/mdbook/src/theme/book.js
index 67a8a5b08..aa12e7ecc 100644
--- a/vendor/mdbook/src/theme/book.js
+++ b/vendor/mdbook/src/theme/book.js
@@ -346,7 +346,7 @@ function playground_text(playground, hidden = true) {
}
setTimeout(function () {
- themeColorMetaTag.content = getComputedStyle(document.body).backgroundColor;
+ themeColorMetaTag.content = getComputedStyle(document.documentElement).backgroundColor;
}, 1);
if (window.ace && window.editors) {
@@ -441,7 +441,7 @@ function playground_text(playground, hidden = true) {
})();
(function sidebar() {
- var html = document.querySelector("html");
+ var body = document.querySelector("body");
var sidebar = document.getElementById("sidebar");
var sidebarLinks = document.querySelectorAll('#sidebar a');
var sidebarToggleButton = document.getElementById("sidebar-toggle");
@@ -449,8 +449,8 @@ function playground_text(playground, hidden = true) {
var firstContact = null;
function showSidebar() {
- html.classList.remove('sidebar-hidden')
- html.classList.add('sidebar-visible');
+ body.classList.remove('sidebar-hidden')
+ body.classList.add('sidebar-visible');
Array.from(sidebarLinks).forEach(function (link) {
link.setAttribute('tabIndex', 0);
});
@@ -471,8 +471,8 @@ function playground_text(playground, hidden = true) {
});
function hideSidebar() {
- html.classList.remove('sidebar-visible')
- html.classList.add('sidebar-hidden');
+ body.classList.remove('sidebar-visible')
+ body.classList.add('sidebar-hidden');
Array.from(sidebarLinks).forEach(function (link) {
link.setAttribute('tabIndex', -1);
});
@@ -483,14 +483,14 @@ function playground_text(playground, hidden = true) {
// Toggle sidebar
sidebarToggleButton.addEventListener('click', function sidebarToggle() {
- if (html.classList.contains("sidebar-hidden")) {
+ if (body.classList.contains("sidebar-hidden")) {
var current_width = parseInt(
document.documentElement.style.getPropertyValue('--sidebar-width'), 10);
if (current_width < 150) {
document.documentElement.style.setProperty('--sidebar-width', '150px');
}
showSidebar();
- } else if (html.classList.contains("sidebar-visible")) {
+ } else if (body.classList.contains("sidebar-visible")) {
hideSidebar();
} else {
if (getComputedStyle(sidebar)['transform'] === 'none') {
@@ -506,14 +506,14 @@ function playground_text(playground, hidden = true) {
function initResize(e) {
window.addEventListener('mousemove', resize, false);
window.addEventListener('mouseup', stopResize, false);
- html.classList.add('sidebar-resizing');
+ body.classList.add('sidebar-resizing');
}
function resize(e) {
var pos = (e.clientX - sidebar.offsetLeft);
if (pos < 20) {
hideSidebar();
} else {
- if (html.classList.contains("sidebar-hidden")) {
+ if (body.classList.contains("sidebar-hidden")) {
showSidebar();
}
pos = Math.min(pos, window.innerWidth - 100);
@@ -522,7 +522,7 @@ function playground_text(playground, hidden = true) {
}
//on mouseup remove windows functions mousemove & mouseup
function stopResize(e) {
- html.classList.remove('sidebar-resizing');
+ body.classList.remove('sidebar-resizing');
window.removeEventListener('mousemove', resize, false);
window.removeEventListener('mouseup', stopResize, false);
}
@@ -557,20 +557,35 @@ function playground_text(playground, hidden = true) {
document.addEventListener('keydown', function (e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
if (window.search && window.search.hasFocus()) { return; }
+ var html = document.querySelector('html');
+ function next() {
+ var nextButton = document.querySelector('.nav-chapters.next');
+ if (nextButton) {
+ window.location.href = nextButton.href;
+ }
+ }
+ function prev() {
+ var previousButton = document.querySelector('.nav-chapters.previous');
+ if (previousButton) {
+ window.location.href = previousButton.href;
+ }
+ }
switch (e.key) {
case 'ArrowRight':
e.preventDefault();
- var nextButton = document.querySelector('.nav-chapters.next');
- if (nextButton) {
- window.location.href = nextButton.href;
+ if (html.dir == 'rtl') {
+ prev();
+ } else {
+ next();
}
break;
case 'ArrowLeft':
e.preventDefault();
- var previousButton = document.querySelector('.nav-chapters.previous');
- if (previousButton) {
- window.location.href = previousButton.href;
+ if (html.dir == 'rtl') {
+ next();
+ } else {
+ prev();
}
break;
}
diff --git a/vendor/mdbook/src/theme/css/chrome.css b/vendor/mdbook/src/theme/css/chrome.css
index 29992f7b6..8b78255de 100644
--- a/vendor/mdbook/src/theme/css/chrome.css
+++ b/vendor/mdbook/src/theme/css/chrome.css
@@ -37,9 +37,9 @@ a > .hljs {
display: flex;
flex-wrap: wrap;
background-color: var(--bg);
- border-bottom-color: var(--bg);
- border-bottom-width: 1px;
- border-bottom-style: solid;
+ border-block-end-color: var(--bg);
+ border-block-end-width: 1px;
+ border-block-end-style: solid;
}
#menu-bar.sticky,
.js #menu-bar-hover-placeholder:hover + #menu-bar,
@@ -56,7 +56,7 @@ a > .hljs {
height: var(--menu-bar-height);
}
#menu-bar.bordered {
- border-bottom-color: var(--table-border-color);
+ border-block-end-color: var(--table-border-color);
}
#menu-bar i, #menu-bar .icon-button {
position: relative;
@@ -93,7 +93,7 @@ a > .hljs {
display: flex;
margin: 0 5px;
}
-.no-js .left-buttons {
+.no-js .left-buttons button {
display: none;
}
@@ -160,7 +160,7 @@ a > .hljs {
}
.nav-wrapper {
- margin-top: 50px;
+ margin-block-start: 50px;
display: none;
}
@@ -173,23 +173,34 @@ a > .hljs {
background-color: var(--sidebar-bg);
}
-.previous {
- float: left;
-}
+/* Only Firefox supports flow-relative values */
+.previous { float: left; }
+[dir=rtl] .previous { float: right; }
+/* Only Firefox supports flow-relative values */
.next {
float: right;
right: var(--page-padding);
}
+[dir=rtl] .next {
+ float: left;
+ right: unset;
+ left: var(--page-padding);
+}
+
+/* Use the correct buttons for RTL layouts*/
+[dir=rtl] .previous i.fa-angle-left:before {content:"\f105";}
+[dir=rtl] .next i.fa-angle-right:before { content:"\f104"; }
@media only screen and (max-width: 1080px) {
.nav-wide-wrapper { display: none; }
.nav-wrapper { display: block; }
}
+/* sidebar-visible */
@media only screen and (max-width: 1380px) {
- .sidebar-visible .nav-wide-wrapper { display: none; }
- .sidebar-visible .nav-wrapper { display: block; }
+ #sidebar-toggle-anchor:checked ~ .page-wrapper .nav-wide-wrapper { display: none; }
+ #sidebar-toggle-anchor:checked ~ .page-wrapper .nav-wrapper { display: block; }
}
/* Inline code */
@@ -236,7 +247,7 @@ pre > .buttons :hover {
background-color: var(--theme-hover);
}
pre > .buttons i {
- margin-left: 8px;
+ margin-inline-start: 8px;
}
pre > .buttons button {
cursor: inherit;
@@ -258,8 +269,14 @@ pre > .buttons button {
/* On mobile, make it easier to tap buttons. */
padding: 0.3rem 1rem;
}
+
+ .sidebar-resize-indicator {
+ /* Hide resize indicator on devices with limited accuracy */
+ display: none;
+ }
}
pre > code {
+ display: block;
padding: 1rem;
}
@@ -273,7 +290,7 @@ pre > code {
}
pre > .result {
- margin-top: 10px;
+ margin-block-start: 10px;
}
/* Search */
@@ -284,8 +301,14 @@ pre > .result {
mark {
border-radius: 2px;
- padding: 0 3px 1px 3px;
- margin: 0 -3px -1px -3px;
+ padding-block-start: 0;
+ padding-block-end: 1px;
+ padding-inline-start: 3px;
+ padding-inline-end: 3px;
+ margin-block-start: 0;
+ margin-block-end: -1px;
+ margin-inline-start: -3px;
+ margin-inline-end: -3px;
background-color: var(--search-mark-bg);
transition: background-color 300ms linear;
cursor: pointer;
@@ -297,14 +320,17 @@ mark.fade-out {
}
.searchbar-outer {
- margin-left: auto;
- margin-right: auto;
+ margin-inline-start: auto;
+ margin-inline-end: auto;
max-width: var(--content-max-width);
}
#searchbar {
width: 100%;
- margin: 5px auto 0px auto;
+ margin-block-start: 5px;
+ margin-block-end: 0;
+ margin-inline-start: auto;
+ margin-inline-end: auto;
padding: 10px 16px;
transition: box-shadow 300ms ease-in-out;
border: 1px solid var(--searchbar-border-color);
@@ -320,20 +346,23 @@ mark.fade-out {
.searchresults-header {
font-weight: bold;
font-size: 1em;
- padding: 18px 0 0 5px;
+ padding-block-start: 18px;
+ padding-block-end: 0;
+ padding-inline-start: 5px;
+ padding-inline-end: 0;
color: var(--searchresults-header-fg);
}
.searchresults-outer {
- margin-left: auto;
- margin-right: auto;
+ margin-inline-start: auto;
+ margin-inline-end: auto;
max-width: var(--content-max-width);
- border-bottom: 1px dashed var(--searchresults-border-color);
+ border-block-end: 1px dashed var(--searchresults-border-color);
}
ul#searchresults {
list-style: none;
- padding-left: 20px;
+ padding-inline-start: 20px;
}
ul#searchresults li {
margin: 10px 0px;
@@ -346,7 +375,10 @@ ul#searchresults li.focus {
ul#searchresults span.teaser {
display: block;
clear: both;
- margin: 5px 0 0 20px;
+ margin-block-start: 5px;
+ margin-block-end: 0;
+ margin-inline-start: 20px;
+ margin-inline-end: 0;
font-size: 0.8em;
}
ul#searchresults span.teaser em {
@@ -369,12 +401,14 @@ ul#searchresults span.teaser em {
background-color: var(--sidebar-bg);
color: var(--sidebar-fg);
}
+[dir=rtl] .sidebar { left: unset; right: 0; }
.sidebar-resizing {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
+.no-js .sidebar,
.js:not(.sidebar-resizing) .sidebar {
transition: transform 0.3s; /* Animation: slide away */
}
@@ -394,16 +428,35 @@ ul#searchresults span.teaser em {
position: absolute;
cursor: col-resize;
width: 0;
- right: 0;
+ right: calc(var(--sidebar-resize-indicator-width) * -1);
top: 0;
bottom: 0;
+ display: flex;
+ align-items: center;
+}
+
+.sidebar-resize-handle .sidebar-resize-indicator {
+ width: 100%;
+ height: 12px;
+ background-color: var(--icons);
+ margin-inline-start: var(--sidebar-resize-indicator-space);
+}
+
+[dir=rtl] .sidebar .sidebar-resize-handle {
+ left: calc(var(--sidebar-resize-indicator-width) * -1);
+ right: unset;
}
.js .sidebar .sidebar-resize-handle {
cursor: col-resize;
- width: 5px;
+ width: calc(var(--sidebar-resize-indicator-width) - var(--sidebar-resize-indicator-space));
}
-.sidebar-hidden .sidebar {
- transform: translateX(calc(0px - var(--sidebar-width)));
+/* sidebar-hidden */
+#sidebar-toggle-anchor:not(:checked) ~ .sidebar {
+ transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width)));
+ z-index: -1;
+}
+[dir=rtl] #sidebar-toggle-anchor:not(:checked) ~ .sidebar {
+ transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)));
}
.sidebar::-webkit-scrollbar {
background: var(--sidebar-bg);
@@ -412,19 +465,26 @@ ul#searchresults span.teaser em {
background: var(--scrollbar);
}
-.sidebar-visible .page-wrapper {
- transform: translateX(var(--sidebar-width));
+/* sidebar-visible */
+#sidebar-toggle-anchor:checked ~ .page-wrapper {
+ transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)));
+}
+[dir=rtl] #sidebar-toggle-anchor:checked ~ .page-wrapper {
+ transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width)));
}
@media only screen and (min-width: 620px) {
- .sidebar-visible .page-wrapper {
+ #sidebar-toggle-anchor:checked ~ .page-wrapper {
+ transform: none;
+ margin-inline-start: calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width));
+ }
+ [dir=rtl] #sidebar-toggle-anchor:checked ~ .page-wrapper {
transform: none;
- margin-left: var(--sidebar-width);
}
}
.chapter {
list-style: none outside none;
- padding-left: 0;
+ padding-inline-start: 0;
line-height: 2.2em;
}
@@ -454,7 +514,7 @@ ul#searchresults span.teaser em {
.chapter li > a.toggle {
cursor: pointer;
display: block;
- margin-left: auto;
+ margin-inline-start: auto;
padding: 0 10px;
user-select: none;
opacity: 0.68;
@@ -471,7 +531,7 @@ ul#searchresults span.teaser em {
.chapter li.chapter-item {
line-height: 1.5em;
- margin-top: 0.6em;
+ margin-block-start: 0.6em;
}
.chapter li.expanded > a.toggle div {
@@ -494,7 +554,7 @@ ul#searchresults span.teaser em {
.section {
list-style: none outside none;
- padding-left: 20px;
+ padding-inline-start: 20px;
line-height: 1.9em;
}
@@ -517,6 +577,7 @@ ul#searchresults span.teaser em {
/* Don't let the children's background extend past the rounded corners. */
overflow: hidden;
}
+[dir=rtl] .theme-popup { left: unset; right: 10px; }
.theme-popup .default {
color: var(--icons);
}
@@ -527,7 +588,7 @@ ul#searchresults span.teaser em {
padding: 2px 20px;
line-height: 25px;
white-space: nowrap;
- text-align: left;
+ text-align: start;
cursor: pointer;
color: inherit;
background: inherit;
@@ -540,6 +601,6 @@ ul#searchresults span.teaser em {
.theme-selected::before {
display: inline-block;
content: "✓";
- margin-left: -14px;
+ margin-inline-start: -14px;
width: 14px;
}
diff --git a/vendor/mdbook/src/theme/css/general.css b/vendor/mdbook/src/theme/css/general.css
index 344b53eb7..e7d20da72 100644
--- a/vendor/mdbook/src/theme/css/general.css
+++ b/vendor/mdbook/src/theme/css/general.css
@@ -5,6 +5,7 @@
:root {
/* Browser default font-size is 16px, this way 1 rem = 10px */
font-size: 62.5%;
+ color-scheme: var(--color-scheme);
}
html {
@@ -24,6 +25,7 @@ body {
code {
font-family: var(--mono-font) !important;
font-size: var(--code-font-size);
+ direction: ltr !important;
}
/* make long words/inline code not x overflow */
@@ -47,13 +49,13 @@ h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
.hide-boring .boring { display: none; }
.hidden { display: none !important; }
-h2, h3 { margin-top: 2.5em; }
-h4, h5 { margin-top: 2em; }
+h2, h3 { margin-block-start: 2.5em; }
+h4, h5 { margin-block-start: 2em; }
.header + .header h3,
.header + .header h4,
.header + .header h5 {
- margin-top: 1em;
+ margin-block-start: 1em;
}
h1:target::before,
@@ -64,7 +66,7 @@ h5:target::before,
h6:target::before {
display: inline-block;
content: "»";
- margin-left: -30px;
+ margin-inline-start: -30px;
width: 30px;
}
@@ -73,28 +75,34 @@ h6:target::before {
https://bugs.webkit.org/show_bug.cgi?id=218076
*/
:target {
+ /* Safari does not support logical properties */
scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
}
.page {
outline: 0;
padding: 0 var(--page-padding);
- margin-top: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */
+ margin-block-start: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */
}
.page-wrapper {
box-sizing: border-box;
+ background-color: var(--bg);
}
+.no-js .page-wrapper,
.js:not(.sidebar-resizing) .page-wrapper {
transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}
+[dir=rtl] .js:not(.sidebar-resizing) .page-wrapper {
+ transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
+}
.content {
overflow-y: auto;
padding: 0 5px 50px 5px;
}
.content main {
- margin-left: auto;
- margin-right: auto;
+ margin-inline-start: auto;
+ margin-inline-end: auto;
max-width: var(--content-max-width);
}
.content p { line-height: 1.45em; }
@@ -144,8 +152,31 @@ blockquote {
padding: 0 20px;
color: var(--fg);
background-color: var(--quote-bg);
- border-top: .1em solid var(--quote-border);
- border-bottom: .1em solid var(--quote-border);
+ border-block-start: .1em solid var(--quote-border);
+ border-block-end: .1em solid var(--quote-border);
+}
+
+.warning {
+ margin: 20px;
+ padding: 0 20px;
+ border-inline-start: 2px solid var(--warning-border);
+}
+
+.warning:before {
+ position: absolute;
+ width: 3rem;
+ height: 3rem;
+ margin-inline-start: calc(-1.5rem - 21px);
+ content: "ⓘ";
+ text-align: center;
+ background-color: var(--bg);
+ color: var(--warning-border);
+ font-weight: bold;
+ font-size: 2rem;
+}
+
+blockquote .warning:before {
+ background-color: var(--quote-bg);
}
kbd {
@@ -163,7 +194,7 @@ kbd {
:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
- margin-top: 2em;
+ margin-block-start: 2em;
}
.footnote-definition {
font-size: 0.9em;
diff --git a/vendor/mdbook/src/theme/css/print.css b/vendor/mdbook/src/theme/css/print.css
index 5e690f755..80ec3a544 100644
--- a/vendor/mdbook/src/theme/css/print.css
+++ b/vendor/mdbook/src/theme/css/print.css
@@ -7,8 +7,8 @@
}
#page-wrapper.page-wrapper {
- transform: none;
- margin-left: 0px;
+ transform: none !important;
+ margin-inline-start: 0px;
overflow-y: initial;
}
@@ -23,11 +23,7 @@
}
code {
- background-color: #666666;
- border-radius: 5px;
-
- /* Force background to be printed in Chrome */
- -webkit-print-color-adjust: exact;
+ direction: ltr !important;
}
pre > .buttons {
diff --git a/vendor/mdbook/src/theme/css/variables.css b/vendor/mdbook/src/theme/css/variables.css
index 21bf8e55e..0da55e8c9 100644
--- a/vendor/mdbook/src/theme/css/variables.css
+++ b/vendor/mdbook/src/theme/css/variables.css
@@ -3,6 +3,8 @@
:root {
--sidebar-width: 300px;
+ --sidebar-resize-indicator-width: 8px;
+ --sidebar-resize-indicator-space: 2px;
--page-padding: 15px;
--content-max-width: 750px;
--menu-bar-height: 50px;
@@ -38,6 +40,8 @@
--quote-bg: hsl(226, 15%, 17%);
--quote-border: hsl(226, 15%, 22%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(210, 25%, 13%);
--table-header-bg: hsl(210, 25%, 28%);
--table-alternate-bg: hsl(210, 25%, 11%);
@@ -50,6 +54,8 @@
--searchresults-border-color: #888;
--searchresults-li-bg: #252932;
--search-mark-bg: #e3b171;
+
+ --color-scheme: dark;
}
.coal {
@@ -78,6 +84,8 @@
--quote-bg: hsl(234, 21%, 18%);
--quote-border: hsl(234, 21%, 23%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(200, 7%, 13%);
--table-header-bg: hsl(200, 7%, 28%);
--table-alternate-bg: hsl(200, 7%, 11%);
@@ -90,6 +98,8 @@
--searchresults-border-color: #98a3ad;
--searchresults-li-bg: #2b2b2f;
--search-mark-bg: #355c7d;
+
+ --color-scheme: dark;
}
.light {
@@ -118,6 +128,8 @@
--quote-bg: hsl(197, 37%, 96%);
--quote-border: hsl(197, 37%, 91%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(0, 0%, 95%);
--table-header-bg: hsl(0, 0%, 80%);
--table-alternate-bg: hsl(0, 0%, 97%);
@@ -130,6 +142,8 @@
--searchresults-border-color: #888;
--searchresults-li-bg: #e4f2fe;
--search-mark-bg: #a2cff5;
+
+ --color-scheme: light;
}
.navy {
@@ -158,6 +172,8 @@
--quote-bg: hsl(226, 15%, 17%);
--quote-border: hsl(226, 15%, 22%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(226, 23%, 16%);
--table-header-bg: hsl(226, 23%, 31%);
--table-alternate-bg: hsl(226, 23%, 14%);
@@ -170,6 +186,8 @@
--searchresults-border-color: #5c5c68;
--searchresults-li-bg: #242430;
--search-mark-bg: #a2cff5;
+
+ --color-scheme: dark;
}
.rust {
@@ -198,6 +216,8 @@
--quote-bg: hsl(60, 5%, 75%);
--quote-border: hsl(60, 5%, 70%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(60, 9%, 82%);
--table-header-bg: #b3a497;
--table-alternate-bg: hsl(60, 9%, 84%);
@@ -210,6 +230,8 @@
--searchresults-border-color: #888;
--searchresults-li-bg: #dec2a2;
--search-mark-bg: #e69f67;
+
+ --color-scheme: light;
}
@media (prefers-color-scheme: dark) {
@@ -239,6 +261,8 @@
--quote-bg: hsl(234, 21%, 18%);
--quote-border: hsl(234, 21%, 23%);
+ --warning-border: #ff8e00;
+
--table-border-color: hsl(200, 7%, 13%);
--table-header-bg: hsl(200, 7%, 28%);
--table-alternate-bg: hsl(200, 7%, 11%);
diff --git a/vendor/mdbook/src/theme/index.hbs b/vendor/mdbook/src/theme/index.hbs
index 80315c48f..080b78516 100644
--- a/vendor/mdbook/src/theme/index.hbs
+++ b/vendor/mdbook/src/theme/index.hbs
@@ -1,11 +1,11 @@
<!DOCTYPE HTML>
-<html lang="{{ language }}" class="sidebar-visible no-js {{ default_theme }}">
+<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
- <meta name="robots" content="noindex" />
+ <meta name="robots" content="noindex">
{{/if}}
{{#if base_url}}
<base href="{{ base_url }}">
@@ -17,7 +17,7 @@
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="theme-color" content="#ffffff" />
+ <meta name="theme-color" content="#ffffff">
{{#if favicon_svg}}
<link rel="icon" href="{{ path_to_root }}favicon.svg">
@@ -53,7 +53,7 @@
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
</head>
- <body>
+ <body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
@@ -83,31 +83,38 @@
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
- html.classList.remove('no-js')
html.classList.remove('{{ default_theme }}')
html.classList.add(theme);
- html.classList.add('js');
+ var body = document.querySelector('body');
+ body.classList.remove('no-js')
+ body.classList.add('js');
</script>
+ <input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
+
<!-- Hide / unhide sidebar before it is displayed -->
<script>
- var html = document.querySelector('html');
+ var body = document.querySelector('body');
var sidebar = null;
+ var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
- html.classList.remove('sidebar-visible');
- html.classList.add("sidebar-" + sidebar);
+ sidebar_toggle.checked = sidebar === 'visible';
+ body.classList.remove('sidebar-visible');
+ body.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
{{#toc}}{{/toc}}
</div>
- <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
+ <div id="sidebar-resize-handle" class="sidebar-resize-handle">
+ <div class="sidebar-resize-indicator"></div>
+ </div>
</nav>
<!-- Track and set sidebar scroll position -->
@@ -139,9 +146,9 @@
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
- <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
+ <label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
- </button>
+ </label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
@@ -217,7 +224,7 @@
{{/previous}}
{{#next}}
- <a rel="next" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
+ <a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
@@ -235,7 +242,7 @@
{{/previous}}
{{#next}}
- <a rel="next" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
+ <a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
diff --git a/vendor/mdbook/src/utils/fs.rs b/vendor/mdbook/src/utils/fs.rs
index 8ad5aad8b..1c3132162 100644
--- a/vendor/mdbook/src/utils/fs.rs
+++ b/vendor/mdbook/src/utils/fs.rs
@@ -166,7 +166,7 @@ pub fn copy_files_except_ext(
.expect("a file should have a file name...")
)
);
- fs::copy(
+ copy(
entry.path(),
&to.join(
entry
@@ -180,6 +180,62 @@ pub fn copy_files_except_ext(
Ok(())
}
+/// Copies a file.
+fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<()> {
+ let from = from.as_ref();
+ let to = to.as_ref();
+ return copy_inner(from, to)
+ .with_context(|| format!("failed to copy `{}` to `{}`", from.display(), to.display()));
+
+ // This is a workaround for an issue with the macOS file watcher.
+ // Rust's `std::fs::copy` function uses `fclonefileat`, which creates
+ // clones on APFS. Unfortunately fs events seem to trigger on both
+ // sides of the clone, and there doesn't seem to be a way to differentiate
+ // which side it is.
+ // https://github.com/notify-rs/notify/issues/465#issuecomment-1657261035
+ // contains more information.
+ //
+ // This is essentially a copy of the simple copy code path in Rust's
+ // standard library.
+ #[cfg(target_os = "macos")]
+ fn copy_inner(from: &Path, to: &Path) -> Result<()> {
+ use std::fs::OpenOptions;
+ use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
+
+ let mut reader = File::open(from)?;
+ let metadata = reader.metadata()?;
+ if !metadata.is_file() {
+ anyhow::bail!(
+ "expected a file, `{}` appears to be {:?}",
+ from.display(),
+ metadata.file_type()
+ );
+ }
+ let perm = metadata.permissions();
+ let mut writer = OpenOptions::new()
+ .mode(perm.mode())
+ .write(true)
+ .create(true)
+ .truncate(true)
+ .open(to)?;
+ let writer_metadata = writer.metadata()?;
+ if writer_metadata.is_file() {
+ // Set the correct file permissions, in case the file already existed.
+ // Don't set the permissions on already existing non-files like
+ // pipes/FIFOs or device nodes.
+ writer.set_permissions(perm)?;
+ }
+ std::io::copy(&mut reader, &mut writer)?;
+ Ok(())
+ }
+
+ #[cfg(not(target_os = "macos"))]
+ fn copy_inner(from: &Path, to: &Path) -> Result<()> {
+ fs::copy(from, to)?;
+ Ok(())
+ }
+}
+
pub fn get_404_output_file(input_404: &Option<String>) -> String {
input_404
.as_ref()