diff --git a/Cargo.lock b/Cargo.lock index 626df1f3..1143a86a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,6 +186,37 @@ dependencies = [ "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "darling" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "darling_macro 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darling_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darling_macro" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "debug_unreachable" version = "0.1.1" @@ -247,6 +278,26 @@ dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "failure" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure_derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -262,6 +313,11 @@ dependencies = [ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fsevent" version = "0.4.0" @@ -407,6 +463,11 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "idna" version = "0.1.5" @@ -601,8 +662,8 @@ dependencies = [ "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "staticfile 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "toml-query 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml-query 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1262,6 +1323,17 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synstructure" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempfile" version = "3.0.8" @@ -1342,7 +1414,7 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1350,14 +1422,26 @@ dependencies = [ [[package]] name = "toml-query" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "toml-query_derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1594,6 +1678,9 @@ dependencies = [ "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum ctor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3b4c17619643c1252b5f690084b82639dd7fac141c57c8e77a00e0148132092c" +"checksum darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9158d690bc62a3a57c3e45b85e4d50de2008b39345592c64efd79345c7e24be0" +"checksum darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d2a368589465391e127e10c9e3a08efc8df66fd49b87dc8524c764bbe7f2ef82" +"checksum darling_macro 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "244e8987bd4e174385240cde20a3657f607fb0797563c28255c353b5819a07b1" "checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" @@ -1601,8 +1688,11 @@ dependencies = [ "checksum elasticlunr-rs 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" "checksum fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" @@ -1619,6 +1709,7 @@ dependencies = [ "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" +"checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" @@ -1718,6 +1809,7 @@ dependencies = [ "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" "checksum tendril 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1b72f8e2f5b73b65c315b1a70c730f24b9d7a25f39e98de8acbe2bb795caea" "checksum tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b" @@ -1726,8 +1818,9 @@ dependencies = [ "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum toml-query 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab234a943a2363ad774020e2f9474a38a85bc4396bace01a96380144aef17db3" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" +"checksum toml-query 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a24369a1894ac8224efcfd567c3d141aea360292f49888e7ec7dcc316527aebb" +"checksum toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c99ca245ec273c7e75c8ee58f47b882d0146f3c2c8495158082c6671e8b5335" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" diff --git a/Cargo.toml b/Cargo.toml index 5caef5c6..8e4726a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,25 +16,25 @@ repository = "https://github.com/rust-lang-nursery/mdBook" description = "Creates a book from markdown files" [dependencies] -clap = "2.24" chrono = "0.4" -handlebars = { version = "1.0", default-features = false, features = ["no_dir_source"] } -serde = "1.0" -serde_derive = "1.0" +clap = "2.24" +env_logger = "0.6" error-chain = "0.12" -serde_json = "1.0" -pulldown-cmark = "0.1.2" +handlebars = { version = "1.0", default-features = false, features = ["no_dir_source"] } +itertools = "0.8" lazy_static = "1.0" log = "0.4" -env_logger = "0.6" -toml = "0.4.8" memchr = "2.0" open = "1.1" +pulldown-cmark = "0.1.2" regex = "1.0.0" -tempfile = "3.0" -itertools = "0.8" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" shlex = "0.1" -toml-query = "0.7" +tempfile = "3.0" +toml = "0.5.1" +toml-query = "0.9" glob = "0.3.0" # Watch feature diff --git a/src/book/mod.rs b/src/book/mod.rs index 3b25c68e..c8a7bfce 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -68,7 +68,7 @@ impl MDBook { config.update_from_env(); - if log_enabled!(::log::Level::Trace) { + if log_enabled!(log::Level::Trace) { for line in format!("Config: {:#?}", config).lines() { trace!("{}", line); } @@ -525,7 +525,7 @@ mod tests { #[test] fn can_determine_third_party_preprocessors() { - let cfg_str: &'static str = r#" + let cfg_str = r#" [book] title = "Some Book" @@ -564,7 +564,7 @@ mod tests { #[test] fn config_respects_preprocessor_selection() { - let cfg_str: &'static str = r#" + let cfg_str = r#" [preprocessor.links] renderers = ["html"] "#; diff --git a/src/cmd/clean.rs b/src/cmd/clean.rs index 420037d7..07c2fbc6 100644 --- a/src/cmd/clean.rs +++ b/src/cmd/clean.rs @@ -21,7 +21,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { } // 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 = MDBook::load(&book_dir)?; diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 502fd7fd..3accad93 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -83,14 +83,14 @@ where Ok(w) => w, Err(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 if let Err(e) = watcher.watch(book.source_dir(), Recursive) { error!("Error while watching {:?}:\n {:?}", book.source_dir(), e); - ::std::process::exit(1); + std::process::exit(1); }; let _ = watcher.watch(book.theme_dir(), Recursive); diff --git a/src/config.rs b/src/config.rs index eff0505d..9c88f910 100644 --- a/src/config.rs +++ b/src/config.rs @@ -206,7 +206,9 @@ impl Config { } else if index.starts_with("build.") { self.build.update_value(&index[6..], value); } else { - self.rest.insert(index, value)?; + self.rest + .insert(index, value) + .map_err(|e| ErrorKind::TomlQueryError(e))?; } Ok(()) @@ -268,7 +270,7 @@ impl Default for Config { } } impl<'de> Deserialize<'de> for Config { - fn deserialize>(de: D) -> ::std::result::Result { + fn deserialize>(de: D) -> std::result::Result { let raw = Value::deserialize(de)?; if is_legacy_format(&raw) { @@ -312,7 +314,7 @@ impl<'de> Deserialize<'de> for Config { } impl Serialize for Config { - fn serialize(&self, s: S) -> ::std::result::Result { + fn serialize(&self, s: S) -> std::result::Result { use serde::ser::Error; let mut table = self.rest.clone(); diff --git a/src/lib.rs b/src/lib.rs index 0494d984..1a1ce85c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,20 +122,16 @@ pub mod errors { error_chain! { foreign_links { - Io(::std::io::Error) #[doc = "A wrapper around `std::io::Error`"]; - HandlebarsRender(::handlebars::RenderError) #[doc = "Handlebars rendering failed"]; - HandlebarsTemplate(Box<::handlebars::TemplateError>) #[doc = "Unable to parse the template"]; - Utf8(::std::string::FromUtf8Error) #[doc = "Invalid UTF-8"]; - SerdeJson(::serde_json::Error) #[doc = "JSON conversion failed"]; - } - - links { - TomlQuery(::toml_query::error::Error, ::toml_query::error::ErrorKind) #[doc = "A TomlQuery error"]; + Io(std::io::Error) #[doc = "A wrapper around `std::io::Error`"]; + HandlebarsRender(handlebars::RenderError) #[doc = "Handlebars rendering failed"]; + HandlebarsTemplate(Box) #[doc = "Unable to parse the template"]; + Utf8(std::string::FromUtf8Error) #[doc = "Invalid UTF-8"]; + SerdeJson(serde_json::Error) #[doc = "JSON conversion failed"]; } errors { /// 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") display("{}: {}", message, String::from_utf8_lossy(&output.stdout)) } @@ -151,12 +147,18 @@ pub mod errors { description("Reserved Filename") display("{} is reserved for internal use", filename.display()) } + + /// Error with a TOML file. + TomlQueryError(inner: toml_query::error::Error) { + description("toml_query error") + display("{}", inner) + } } } // Box to halve the size of Error - impl From<::handlebars::TemplateError> for Error { - fn from(e: ::handlebars::TemplateError) -> Error { + impl From for Error { + fn from(e: handlebars::TemplateError) -> Error { From::from(Box::new(e)) } } diff --git a/src/main.rs b/src/main.rs index 22aac744..14aad67a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ fn main() { if let Err(e) = res { utils::log_backtrace(&e); - ::std::process::exit(101); + std::process::exit(101); } } diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index 9264d598..4d162af7 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -171,7 +171,7 @@ pub fn next( mod tests { use super::*; - static TEMPLATE: &'static str = + static TEMPLATE: &str = "{{#previous}}{{title}}: {{link}}{{/previous}}|{{#next}}{{title}}: {{link}}{{/next}}"; #[test] diff --git a/src/theme/book.js b/src/theme/book.js index 1aff593f..ca73ee14 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -101,11 +101,15 @@ function playpen_text(playpen) { } let text = playpen_text(code_block); + let classes = code_block.querySelector('code').classList; + let has_2018 = classes.contains("edition2018"); + let edition = has_2018 ? "2018" : "2015"; var params = { version: "stable", optimize: "0", - code: text + code: text, + edition: edition }; if (text.indexOf("#![feature") !== -1) { diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 3598322a..aab96db7 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -11,31 +11,27 @@ use std::path::Path; use crate::errors::*; -pub static INDEX: &'static [u8] = include_bytes!("index.hbs"); -pub static HEADER: &'static [u8] = include_bytes!("header.hbs"); -pub static CHROME_CSS: &'static [u8] = include_bytes!("css/chrome.css"); -pub static GENERAL_CSS: &'static [u8] = include_bytes!("css/general.css"); -pub static PRINT_CSS: &'static [u8] = include_bytes!("css/print.css"); -pub static VARIABLES_CSS: &'static [u8] = include_bytes!("css/variables.css"); -pub static FAVICON: &'static [u8] = include_bytes!("favicon.png"); -pub static JS: &'static [u8] = include_bytes!("book.js"); -pub static HIGHLIGHT_JS: &'static [u8] = include_bytes!("highlight.js"); -pub static TOMORROW_NIGHT_CSS: &'static [u8] = include_bytes!("tomorrow-night.css"); -pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css"); -pub static AYU_HIGHLIGHT_CSS: &'static [u8] = include_bytes!("ayu-highlight.css"); -pub static CLIPBOARD_JS: &'static [u8] = include_bytes!("clipboard.min.js"); -pub static FONT_AWESOME: &'static [u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); -pub static FONT_AWESOME_EOT: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); -pub static FONT_AWESOME_SVG: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); -pub static FONT_AWESOME_TTF: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.ttf"); -pub static FONT_AWESOME_WOFF: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff"); -pub static FONT_AWESOME_WOFF2: &'static [u8] = +pub static INDEX: &[u8] = include_bytes!("index.hbs"); +pub static HEADER: &[u8] = include_bytes!("header.hbs"); +pub static CHROME_CSS: &[u8] = include_bytes!("css/chrome.css"); +pub static GENERAL_CSS: &[u8] = include_bytes!("css/general.css"); +pub static PRINT_CSS: &[u8] = include_bytes!("css/print.css"); +pub static VARIABLES_CSS: &[u8] = include_bytes!("css/variables.css"); +pub static FAVICON: &[u8] = include_bytes!("favicon.png"); +pub static JS: &[u8] = include_bytes!("book.js"); +pub static HIGHLIGHT_JS: &[u8] = include_bytes!("highlight.js"); +pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("tomorrow-night.css"); +pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("highlight.css"); +pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("ayu-highlight.css"); +pub static CLIPBOARD_JS: &[u8] = include_bytes!("clipboard.min.js"); +pub static FONT_AWESOME: &[u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); +pub static FONT_AWESOME_EOT: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); +pub static FONT_AWESOME_SVG: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); +pub static FONT_AWESOME_TTF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.ttf"); +pub static FONT_AWESOME_WOFF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff"); +pub static FONT_AWESOME_WOFF2: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff2"); -pub static FONT_AWESOME_OTF: &'static [u8] = include_bytes!("FontAwesome/fonts/FontAwesome.otf"); +pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("FontAwesome/fonts/FontAwesome.otf"); /// 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 diff --git a/src/theme/playpen_editor/mod.rs b/src/theme/playpen_editor/mod.rs index 447e81ed..0fdf7132 100644 --- a/src/theme/playpen_editor/mod.rs +++ b/src/theme/playpen_editor/mod.rs @@ -1,7 +1,7 @@ //! Theme dependencies for the playpen editor. -pub static JS: &'static [u8] = include_bytes!("editor.js"); -pub static ACE_JS: &'static [u8] = include_bytes!("ace.js"); -pub static MODE_RUST_JS: &'static [u8] = include_bytes!("mode-rust.js"); -pub static THEME_DAWN_JS: &'static [u8] = include_bytes!("theme-dawn.js"); -pub static THEME_TOMORROW_NIGHT_JS: &'static [u8] = include_bytes!("theme-tomorrow_night.js"); +pub static JS: &[u8] = include_bytes!("editor.js"); +pub static ACE_JS: &[u8] = include_bytes!("ace.js"); +pub static MODE_RUST_JS: &[u8] = include_bytes!("mode-rust.js"); +pub static THEME_DAWN_JS: &[u8] = include_bytes!("theme-dawn.js"); +pub static THEME_TOMORROW_NIGHT_JS: &[u8] = include_bytes!("theme-tomorrow_night.js"); diff --git a/src/theme/searcher/mod.rs b/src/theme/searcher/mod.rs index c80441d0..d5029db1 100644 --- a/src/theme/searcher/mod.rs +++ b/src/theme/searcher/mod.rs @@ -1,6 +1,6 @@ //! Theme dependencies for in-browser search. Not included in mdbook when //! the "search" cargo feature is disabled. -pub static JS: &'static [u8] = include_bytes!("searcher.js"); -pub static MARK_JS: &'static [u8] = include_bytes!("mark.min.js"); -pub static ELASTICLUNR_JS: &'static [u8] = include_bytes!("elasticlunr.min.js"); +pub static JS: &[u8] = include_bytes!("searcher.js"); +pub static MARK_JS: &[u8] = include_bytes!("mark.min.js"); +pub static ELASTICLUNR_JS: &[u8] = include_bytes!("elasticlunr.min.js"); diff --git a/tests/init.rs b/tests/init.rs index d54e4fb1..248cb623 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -35,7 +35,7 @@ fn run_mdbook_init_should_create_content_from_summary() { let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); let src_dir = temp.path().join("src"); fs::create_dir_all(src_dir.clone()).unwrap(); - static SUMMARY: &'static str = r#"# Summary + static SUMMARY: &str = r#"# Summary [intro](intro.md) diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 12aa3a3b..dfee1793 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -403,7 +403,7 @@ fn theme_dir_overrides_work_correctly() { let book_dir = book_dir.path(); 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"); write_file(&theme_dir, "index.hbs", &index).unwrap();