cargo fmt
This commit is contained in:
parent
b30b58b565
commit
0aa3a9045a
|
@ -481,7 +481,8 @@ And here is some \
|
||||||
.filter_map(|i| match *i {
|
.filter_map(|i| match *i {
|
||||||
BookItem::Chapter(ref ch) => Some(ch.name.clone()),
|
BookItem::Chapter(ref ch) => Some(ch.name.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
let should_be: Vec<_> = vec![
|
let should_be: Vec<_> = vec![
|
||||||
String::from("Chapter 1"),
|
String::from("Chapter 1"),
|
||||||
String::from("Hello World"),
|
String::from("Hello World"),
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl MDBook {
|
||||||
pub fn load_with_config_and_summary<P: Into<PathBuf>>(
|
pub fn load_with_config_and_summary<P: Into<PathBuf>>(
|
||||||
book_root: P,
|
book_root: P,
|
||||||
config: Config,
|
config: Config,
|
||||||
summary: Summary
|
summary: Summary,
|
||||||
) -> Result<MDBook> {
|
) -> Result<MDBook> {
|
||||||
let root = book_root.into();
|
let root = book_root.into();
|
||||||
|
|
||||||
|
|
|
@ -477,7 +477,8 @@ fn stringify_events(events: Vec<Event>) -> String {
|
||||||
.filter_map(|t| match t {
|
.filter_map(|t| match t {
|
||||||
Event::Text(text) => Some(text.into_owned()),
|
Event::Text(text) => Some(text.into_owned()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A section number like "1.2.3", basically just a newtype'd `Vec<u32>` with
|
/// A section number like "1.2.3", basically just a newtype'd `Vec<u32>` with
|
||||||
|
|
|
@ -11,10 +11,12 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\
|
"-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\
|
||||||
Relative paths are interpreted relative to the book's root directory.{n}\
|
Relative paths are interpreted relative to the book's root directory.{n}\
|
||||||
If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.'",
|
If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.'",
|
||||||
).arg_from_usage(
|
)
|
||||||
|
.arg_from_usage(
|
||||||
"[dir] 'Root directory for the book{n}\
|
"[dir] 'Root directory for the book{n}\
|
||||||
(Defaults to the Current Directory when omitted)'",
|
(Defaults to the Current Directory when omitted)'",
|
||||||
).arg_from_usage("-o, --open 'Opens the compiled book in a web browser'")
|
)
|
||||||
|
.arg_from_usage("-o, --open 'Opens the compiled book in a web browser'")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build command implementation
|
// Build command implementation
|
||||||
|
|
|
@ -13,7 +13,8 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
Relative paths are interpreted relative to the book's root directory.{n}\
|
Relative paths are interpreted relative to the book's root directory.{n}\
|
||||||
Running this command deletes this directory.{n}\
|
Running this command deletes this directory.{n}\
|
||||||
If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.'",
|
If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.'",
|
||||||
).arg_from_usage(
|
)
|
||||||
|
.arg_from_usage(
|
||||||
"[dir] 'Root directory for the book{n}\
|
"[dir] 'Root directory for the book{n}\
|
||||||
(Defaults to the Current Directory when omitted)'",
|
(Defaults to the Current Directory when omitted)'",
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,8 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
.arg_from_usage(
|
.arg_from_usage(
|
||||||
"[dir] 'Directory to create the book in{n}\
|
"[dir] 'Directory to create the book in{n}\
|
||||||
(Defaults to the Current Directory when omitted)'",
|
(Defaults to the Current Directory when omitted)'",
|
||||||
).arg_from_usage("--theme 'Copies the default theme into your source folder'")
|
)
|
||||||
|
.arg_from_usage("--theme 'Copies the default theme into your source folder'")
|
||||||
.arg_from_usage("--force 'Skips confirmation prompts'")
|
.arg_from_usage("--force 'Skips confirmation prompts'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,8 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
b.config
|
b.config
|
||||||
.set("output.html.livereload-url", &livereload_url)?;
|
.set("output.html.livereload-url", &livereload_url)?;
|
||||||
Ok(b)
|
Ok(b)
|
||||||
}).and_then(|b| b.build());
|
})
|
||||||
|
.and_then(|b| b.build());
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
error!("Unable to load the book");
|
error!("Unable to load the book");
|
||||||
|
|
|
@ -7,8 +7,8 @@ use mdbook::utils;
|
||||||
use mdbook::MDBook;
|
use mdbook::MDBook;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::time::Duration;
|
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
|
use std::time::Duration;
|
||||||
use {get_book_dir, open};
|
use {get_book_dir, open};
|
||||||
|
|
||||||
// Create clap subcommand arguments
|
// Create clap subcommand arguments
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub use renderer::Renderer;
|
||||||
pub mod errors {
|
pub mod errors {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
error_chain!{
|
error_chain! {
|
||||||
foreign_links {
|
foreign_links {
|
||||||
Io(::std::io::Error) #[doc = "A wrapper around `std::io::Error`"];
|
Io(::std::io::Error) #[doc = "A wrapper around `std::io::Error`"];
|
||||||
HandlebarsRender(::handlebars::RenderError) #[doc = "Handlebars rendering failed"];
|
HandlebarsRender(::handlebars::RenderError) #[doc = "Handlebars rendering failed"];
|
||||||
|
|
|
@ -143,7 +143,8 @@ fn parse_include_path(path: &str) -> LinkType<'static> {
|
||||||
match start {
|
match start {
|
||||||
Some(start) => match end {
|
Some(start) => match end {
|
||||||
Some(end) => LinkType::IncludeRange(path, Range { start, end }),
|
Some(end) => LinkType::IncludeRange(path, Range { start, end }),
|
||||||
None => if has_end {
|
None => {
|
||||||
|
if has_end {
|
||||||
LinkType::IncludeRangeFrom(path, RangeFrom { start })
|
LinkType::IncludeRangeFrom(path, RangeFrom { start })
|
||||||
} else {
|
} else {
|
||||||
LinkType::IncludeRange(
|
LinkType::IncludeRange(
|
||||||
|
@ -153,7 +154,8 @@ fn parse_include_path(path: &str) -> LinkType<'static> {
|
||||||
end: start + 1,
|
end: start + 1,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
None => match end {
|
None => match end {
|
||||||
Some(end) => LinkType::IncludeRangeTo(path, RangeTo { end }),
|
Some(end) => LinkType::IncludeRangeTo(path, RangeTo { end }),
|
||||||
|
@ -304,7 +306,8 @@ fn find_links(contents: &str) -> LinkIter {
|
||||||
\s+ # separating whitespace
|
\s+ # separating whitespace
|
||||||
([a-zA-Z0-9\s_.\-:/\\]+) # link target path and space separated properties
|
([a-zA-Z0-9\s_.\-:/\\]+) # link target path and space separated properties
|
||||||
\s*\}\} # whitespace and link closing parens"
|
\s*\}\} # whitespace and link closing parens"
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
LinkIter(RE.captures_iter(contents))
|
LinkIter(RE.captures_iter(contents))
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,11 @@ impl HtmlHandlebars {
|
||||||
|
|
||||||
let string_path = ch.path.parent().unwrap().display().to_string();
|
let string_path = ch.path.parent().unwrap().display().to_string();
|
||||||
|
|
||||||
let fixed_content = utils::render_markdown_with_base(&ch.content, ctx.html_config.curly_quotes, &string_path);
|
let fixed_content = utils::render_markdown_with_base(
|
||||||
|
&ch.content,
|
||||||
|
ctx.html_config.curly_quotes,
|
||||||
|
&string_path,
|
||||||
|
);
|
||||||
print_content.push_str(&fixed_content);
|
print_content.push_str(&fixed_content);
|
||||||
|
|
||||||
// Update the context with data for this file
|
// Update the context with data for this file
|
||||||
|
@ -507,7 +511,8 @@ fn build_header_links(html: &str) -> String {
|
||||||
.expect("Regex should ensure we only ever get numbers here");
|
.expect("Regex should ensure we only ever get numbers here");
|
||||||
|
|
||||||
wrap_header_with_link(level, &caps[2], &mut id_counter)
|
wrap_header_with_link(level, &caps[2], &mut id_counter)
|
||||||
}).into_owned()
|
})
|
||||||
|
.into_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps a single header tag with a link, making sure each tag gets its own
|
/// Wraps a single header tag with a link, making sure each tag gets its own
|
||||||
|
@ -558,7 +563,8 @@ fn fix_code_blocks(html: &str) -> String {
|
||||||
classes = classes,
|
classes = classes,
|
||||||
after = after
|
after = after
|
||||||
)
|
)
|
||||||
}).into_owned()
|
})
|
||||||
|
.into_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
|
fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
|
||||||
|
@ -594,7 +600,8 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
|
||||||
// not language-rust, so no-op
|
// not language-rust, so no-op
|
||||||
text.to_owned()
|
text.to_owned()
|
||||||
}
|
}
|
||||||
}).into_owned()
|
})
|
||||||
|
.into_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn partition_source(s: &str) -> (String, String) {
|
fn partition_source(s: &str) -> (String, String) {
|
||||||
|
|
|
@ -34,7 +34,8 @@ pub fn normalize_id(content: &str) -> String {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}).collect::<String>()
|
})
|
||||||
|
.collect::<String>()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate an ID for use with anchors which is derived from a "normalised"
|
/// Generate an ID for use with anchors which is derived from a "normalised"
|
||||||
|
@ -195,7 +196,8 @@ fn convert_quotes_to_curly(original_text: &str) -> String {
|
||||||
preceded_by_whitespace = original_char.is_whitespace();
|
preceded_by_whitespace = original_char.is_whitespace();
|
||||||
|
|
||||||
converted_char
|
converted_char
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints a "backtrace" of some `Error`.
|
/// Prints a "backtrace" of some `Error`.
|
||||||
|
|
|
@ -30,8 +30,12 @@ const TOC_TOP_LEVEL: &[&'static str] = &[
|
||||||
"Dummy Book",
|
"Dummy Book",
|
||||||
"Introduction",
|
"Introduction",
|
||||||
];
|
];
|
||||||
const TOC_SECOND_LEVEL: &[&'static str] =
|
const TOC_SECOND_LEVEL: &[&'static str] = &[
|
||||||
&["1.1. Nested Chapter", "1.2. Includes", "2.1. Nested Chapter", "1.3. Recursive"];
|
"1.1. Nested Chapter",
|
||||||
|
"1.2. Includes",
|
||||||
|
"2.1. Nested Chapter",
|
||||||
|
"1.3. Recursive",
|
||||||
|
];
|
||||||
|
|
||||||
/// Make sure you can load the dummy book and build it without panicking.
|
/// Make sure you can load the dummy book and build it without panicking.
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue