diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bfd114ca..d5f1add2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - build: msrv os: ubuntu-latest # sync MSRV with docs: guide/src/guide/installation.md - rust: 1.54.0 + rust: 1.56.0 steps: - uses: actions/checkout@master - name: Install Rust diff --git a/Cargo.toml b/Cargo.toml index 60472fb7..b1c095d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ authors = [ "Matt Ickstadt " ] documentation = "http://rust-lang.github.io/mdBook/index.html" -edition = "2018" +edition = "2021" exclude = ["/guide/*"] keywords = ["book", "gitbook", "rustbook", "markdown"] license = "MPL-2.0" diff --git a/src/book/book.rs b/src/book/book.rs index d28c22da..b46843df 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -8,7 +8,7 @@ use super::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem}; use crate::config::BuildConfig; use crate::errors::*; use crate::utils::bracket_escape; - +use log::debug; use serde::{Deserialize, Serialize}; /// Load a book into memory from its `src/` directory. diff --git a/src/book/init.rs b/src/book/init.rs index 264c113d..dd3fa8b0 100644 --- a/src/book/init.rs +++ b/src/book/init.rs @@ -6,6 +6,7 @@ use super::MDBook; use crate::config::Config; use crate::errors::*; use crate::theme; +use log::{debug, error, info, trace}; /// A helper for setting up a new book and its directory structure. #[derive(Debug, Clone, PartialEq)] diff --git a/src/book/mod.rs b/src/book/mod.rs index e407ccc3..5ec64d7c 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -14,6 +14,7 @@ pub use self::book::{load_book, Book, BookItem, BookItems, Chapter}; pub use self::init::BookBuilder; pub use self::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem}; +use log::{debug, error, info, log_enabled, trace, warn}; use std::io::Write; use std::path::PathBuf; use std::process::Command; diff --git a/src/book/summary.rs b/src/book/summary.rs index 2bd81580..02f67c6f 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -1,4 +1,5 @@ use crate::errors::*; +use log::{debug, trace, warn}; use memchr::{self, Memchr}; use pulldown_cmark::{self, Event, HeadingLevel, Tag}; use serde::{Deserialize, Serialize}; diff --git a/src/config.rs b/src/config.rs index b7d03d1a..6b8f1414 100644 --- a/src/config.rs +++ b/src/config.rs @@ -49,6 +49,7 @@ #![deny(missing_docs)] +use log::{debug, trace, warn}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::collections::HashMap; use std::env; @@ -295,7 +296,7 @@ impl Default for Config { } } -impl<'de> Deserialize<'de> for Config { +impl<'de> serde::Deserialize<'de> for Config { fn deserialize>(de: D) -> std::result::Result { let raw = Value::deserialize(de)?; @@ -717,6 +718,7 @@ impl<'de, T> Updateable<'de> for T where T: Serialize + Deserialize<'de> {} mod tests { use super::*; use crate::utils::fs::get_404_output_file; + use serde_json::json; const COMPLEX_CONFIG: &str = r#" [book] diff --git a/src/lib.rs b/src/lib.rs index cc62b0ab..14cd94d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,17 +83,6 @@ #![deny(missing_docs)] #![deny(rust_2018_idioms)] -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_json; - -#[cfg(test)] -#[macro_use] -extern crate pretty_assertions; - pub mod book; pub mod config; pub mod preprocess; diff --git a/src/preprocess/cmd.rs b/src/preprocess/cmd.rs index c47fd5d2..149dabda 100644 --- a/src/preprocess/cmd.rs +++ b/src/preprocess/cmd.rs @@ -1,6 +1,7 @@ use super::{Preprocessor, PreprocessorContext}; use crate::book::Book; use crate::errors::*; +use log::{debug, trace, warn}; use shlex::Shlex; use std::io::{self, Read, Write}; use std::process::{Child, Command, Stdio}; diff --git a/src/preprocess/index.rs b/src/preprocess/index.rs index fd60ad4d..d8a4e375 100644 --- a/src/preprocess/index.rs +++ b/src/preprocess/index.rs @@ -1,10 +1,11 @@ use regex::Regex; use std::path::Path; -use crate::errors::*; - use super::{Preprocessor, PreprocessorContext}; use crate::book::{Book, BookItem}; +use crate::errors::*; +use lazy_static::lazy_static; +use log::warn; /// A preprocessor for converting file name `README.md` to `index.md` since /// `README.md` is the de facto index file in markdown-based documentation. diff --git a/src/preprocess/links.rs b/src/preprocess/links.rs index 7ca6fd34..81575e86 100644 --- a/src/preprocess/links.rs +++ b/src/preprocess/links.rs @@ -10,6 +10,8 @@ use std::path::{Path, PathBuf}; use super::{Preprocessor, PreprocessorContext}; use crate::book::{Book, BookItem}; +use lazy_static::lazy_static; +use log::{error, warn}; const ESCAPE_CHAR: char = '\\'; const MAX_LINK_NESTED_DEPTH: usize = 10; diff --git a/src/preprocess/mod.rs b/src/preprocess/mod.rs index 894e2003..df01a3db 100644 --- a/src/preprocess/mod.rs +++ b/src/preprocess/mod.rs @@ -12,12 +12,11 @@ use crate::book::Book; use crate::config::Config; use crate::errors::*; +use serde::{Deserialize, Serialize}; use std::cell::RefCell; use std::collections::HashMap; use std::path::PathBuf; -use serde::{Deserialize, Serialize}; - /// Extra information for a `Preprocessor` to give them more context when /// processing a book. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 94669cf0..9c126feb 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -14,7 +14,10 @@ use std::path::{Path, PathBuf}; use crate::utils::fs::get_404_output_file; use handlebars::Handlebars; +use lazy_static::lazy_static; +use log::{debug, trace, warn}; use regex::{Captures, Regex}; +use serde_json::json; #[derive(Default)] pub struct HtmlHandlebars; diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index 65929bbf..f57e9ae9 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -4,6 +4,8 @@ use std::path::Path; use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError, Renderable}; use crate::utils; +use log::{debug, trace}; +use serde_json::json; type StringMap = BTreeMap; diff --git a/src/renderer/html_handlebars/helpers/theme.rs b/src/renderer/html_handlebars/helpers/theme.rs index 809ee117..83aba677 100644 --- a/src/renderer/html_handlebars/helpers/theme.rs +++ b/src/renderer/html_handlebars/helpers/theme.rs @@ -1,4 +1,5 @@ use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; +use log::trace; pub fn theme_option( h: &Helper<'_, '_>, diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index c3b944c9..f88893a0 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -10,7 +10,8 @@ use crate::config::Search; use crate::errors::*; use crate::theme::searcher; use crate::utils; - +use lazy_static::lazy_static; +use log::{debug, warn}; use serde::Serialize; const MAX_WORD_LENGTH_TO_INDEX: usize = 80; diff --git a/src/renderer/markdown_renderer.rs b/src/renderer/markdown_renderer.rs index bd5def1f..13bd05cc 100644 --- a/src/renderer/markdown_renderer.rs +++ b/src/renderer/markdown_renderer.rs @@ -2,7 +2,7 @@ use crate::book::BookItem; use crate::errors::*; use crate::renderer::{RenderContext, Renderer}; use crate::utils; - +use log::trace; use std::fs; #[derive(Default)] diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 15465fbc..1c97f8f2 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -27,6 +27,7 @@ use std::process::{Command, Stdio}; use crate::book::Book; use crate::config::Config; use crate::errors::*; +use log::{error, info, trace, warn}; use toml::Value; use serde::{Deserialize, Serialize}; diff --git a/src/theme/mod.rs b/src/theme/mod.rs index a1ee18af..7af5e2b7 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -12,7 +12,7 @@ use std::io::Read; use std::path::Path; use crate::errors::*; - +use log::warn; pub static INDEX: &[u8] = include_bytes!("index.hbs"); pub static HEAD: &[u8] = include_bytes!("head.hbs"); pub static REDIRECT: &[u8] = include_bytes!("redirect.hbs"); diff --git a/src/utils/fs.rs b/src/utils/fs.rs index a933d548..0d6f3837 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -1,4 +1,5 @@ use crate::errors::*; +use log::{debug, trace}; use std::convert::Into; use std::fs::{self, File}; use std::io::Write; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index a205633f..ab1a1bcd 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -4,9 +4,10 @@ pub mod fs; mod string; pub(crate) mod toml_ext; use crate::errors::Error; -use regex::Regex; - +use lazy_static::lazy_static; +use log::error; use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag}; +use regex::Regex; use std::borrow::Cow; use std::collections::HashMap; diff --git a/src/utils/string.rs b/src/utils/string.rs index 97485d7b..bc854347 100644 --- a/src/utils/string.rs +++ b/src/utils/string.rs @@ -1,3 +1,4 @@ +use lazy_static::lazy_static; use regex::Regex; use std::ops::Bound::{Excluded, Included, Unbounded}; use std::ops::RangeBounds;