commit
f4017376a9
20
Cargo.toml
20
Cargo.toml
|
@ -16,24 +16,24 @@ repository = "https://github.com/rust-lang-nursery/mdBook"
|
||||||
description = "Creates a book from markdown files"
|
description = "Creates a book from markdown files"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.24"
|
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
handlebars = { version = "1.0", default-features = false, features = ["no_dir_source"] }
|
clap = "2.24"
|
||||||
serde = "1.0"
|
env_logger = "0.6"
|
||||||
serde_derive = "1.0"
|
|
||||||
error-chain = "0.12"
|
error-chain = "0.12"
|
||||||
serde_json = "1.0"
|
handlebars = { version = "1.0", default-features = false, features = ["no_dir_source"] }
|
||||||
pulldown-cmark = "0.1.2"
|
itertools = "0.8"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.6"
|
|
||||||
toml = "0.4.8"
|
|
||||||
memchr = "2.0"
|
memchr = "2.0"
|
||||||
open = "1.1"
|
open = "1.1"
|
||||||
|
pulldown-cmark = "0.1.2"
|
||||||
regex = "1.0.0"
|
regex = "1.0.0"
|
||||||
tempfile = "3.0"
|
serde = "1.0"
|
||||||
itertools = "0.8"
|
serde_derive = "1.0"
|
||||||
|
serde_json = "1.0"
|
||||||
shlex = "0.1"
|
shlex = "0.1"
|
||||||
|
tempfile = "3.0"
|
||||||
|
toml = "0.4.8"
|
||||||
toml-query = "0.7"
|
toml-query = "0.7"
|
||||||
|
|
||||||
# Watch feature
|
# Watch feature
|
||||||
|
|
|
@ -68,7 +68,7 @@ impl MDBook {
|
||||||
|
|
||||||
config.update_from_env();
|
config.update_from_env();
|
||||||
|
|
||||||
if log_enabled!(::log::Level::Trace) {
|
if log_enabled!(log::Level::Trace) {
|
||||||
for line in format!("Config: {:#?}", config).lines() {
|
for line in format!("Config: {:#?}", config).lines() {
|
||||||
trace!("{}", line);
|
trace!("{}", line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean command implementation
|
// Clean command implementation
|
||||||
pub fn execute(args: &ArgMatches) -> ::mdbook::errors::Result<()> {
|
pub fn execute(args: &ArgMatches) -> mdbook::errors::Result<()> {
|
||||||
let book_dir = get_book_dir(args);
|
let book_dir = get_book_dir(args);
|
||||||
let book = MDBook::load(&book_dir)?;
|
let book = MDBook::load(&book_dir)?;
|
||||||
|
|
||||||
|
|
|
@ -63,14 +63,14 @@ where
|
||||||
Ok(w) => w,
|
Ok(w) => w,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error while trying to watch the files:\n\n\t{:?}", e);
|
error!("Error while trying to watch the files:\n\n\t{:?}", e);
|
||||||
::std::process::exit(1)
|
std::process::exit(1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add the source directory to the watcher
|
// Add the source directory to the watcher
|
||||||
if let Err(e) = watcher.watch(book.source_dir(), Recursive) {
|
if let Err(e) = watcher.watch(book.source_dir(), Recursive) {
|
||||||
error!("Error while watching {:?}:\n {:?}", book.source_dir(), e);
|
error!("Error while watching {:?}:\n {:?}", book.source_dir(), e);
|
||||||
::std::process::exit(1);
|
std::process::exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = watcher.watch(book.theme_dir(), Recursive);
|
let _ = watcher.watch(book.theme_dir(), Recursive);
|
||||||
|
|
|
@ -268,7 +268,7 @@ impl Default for Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'de> Deserialize<'de> for Config {
|
impl<'de> Deserialize<'de> for Config {
|
||||||
fn deserialize<D: Deserializer<'de>>(de: D) -> ::std::result::Result<Self, D::Error> {
|
fn deserialize<D: Deserializer<'de>>(de: D) -> std::result::Result<Self, D::Error> {
|
||||||
let raw = Value::deserialize(de)?;
|
let raw = Value::deserialize(de)?;
|
||||||
|
|
||||||
if is_legacy_format(&raw) {
|
if is_legacy_format(&raw) {
|
||||||
|
@ -312,7 +312,7 @@ impl<'de> Deserialize<'de> for Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for Config {
|
impl Serialize for Config {
|
||||||
fn serialize<S: Serializer>(&self, s: S) -> ::std::result::Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, s: S) -> std::result::Result<S::Ok, S::Error> {
|
||||||
use serde::ser::Error;
|
use serde::ser::Error;
|
||||||
|
|
||||||
let mut table = self.rest.clone();
|
let mut table = self.rest.clone();
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -122,20 +122,20 @@ pub mod errors {
|
||||||
|
|
||||||
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"];
|
||||||
HandlebarsTemplate(Box<::handlebars::TemplateError>) #[doc = "Unable to parse the template"];
|
HandlebarsTemplate(Box<handlebars::TemplateError>) #[doc = "Unable to parse the template"];
|
||||||
Utf8(::std::string::FromUtf8Error) #[doc = "Invalid UTF-8"];
|
Utf8(std::string::FromUtf8Error) #[doc = "Invalid UTF-8"];
|
||||||
SerdeJson(::serde_json::Error) #[doc = "JSON conversion failed"];
|
SerdeJson(serde_json::Error) #[doc = "JSON conversion failed"];
|
||||||
}
|
}
|
||||||
|
|
||||||
links {
|
links {
|
||||||
TomlQuery(::toml_query::error::Error, ::toml_query::error::ErrorKind) #[doc = "A TomlQuery error"];
|
TomlQuery(toml_query::error::Error, toml_query::error::ErrorKind) #[doc = "A TomlQuery error"];
|
||||||
}
|
}
|
||||||
|
|
||||||
errors {
|
errors {
|
||||||
/// A subprocess exited with an unsuccessful return code.
|
/// A subprocess exited with an unsuccessful return code.
|
||||||
Subprocess(message: String, output: ::std::process::Output) {
|
Subprocess(message: String, output: std::process::Output) {
|
||||||
description("A subprocess failed")
|
description("A subprocess failed")
|
||||||
display("{}: {}", message, String::from_utf8_lossy(&output.stdout))
|
display("{}: {}", message, String::from_utf8_lossy(&output.stdout))
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,8 @@ pub mod errors {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Box to halve the size of Error
|
// Box to halve the size of Error
|
||||||
impl From<::handlebars::TemplateError> for Error {
|
impl From<handlebars::TemplateError> for Error {
|
||||||
fn from(e: ::handlebars::TemplateError) -> Error {
|
fn from(e: handlebars::TemplateError) -> Error {
|
||||||
From::from(Box::new(e))
|
From::from(Box::new(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ fn main() {
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
utils::log_backtrace(&e);
|
utils::log_backtrace(&e);
|
||||||
|
|
||||||
::std::process::exit(101);
|
std::process::exit(101);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -403,7 +403,7 @@ fn theme_dir_overrides_work_correctly() {
|
||||||
let book_dir = book_dir.path();
|
let book_dir = book_dir.path();
|
||||||
let theme_dir = book_dir.join("theme");
|
let theme_dir = book_dir.join("theme");
|
||||||
|
|
||||||
let mut index = ::mdbook::theme::INDEX.to_vec();
|
let mut index = mdbook::theme::INDEX.to_vec();
|
||||||
index.extend_from_slice(b"\n<!-- This is a modified index.hbs! -->");
|
index.extend_from_slice(b"\n<!-- This is a modified index.hbs! -->");
|
||||||
|
|
||||||
write_file(&theme_dir, "index.hbs", &index).unwrap();
|
write_file(&theme_dir, "index.hbs", &index).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue