Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
rust: stable
- 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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Matt Ickstadt <[email protected]>"
]
documentation = "http://rust-lang.github.io/mdBook/index.html"
edition = "2018"
edition = "2021"
exclude = ["/guide/*"]
keywords = ["book", "gitbook", "rustbook", "markdown"]
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/book/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/book/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/book/summary.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -295,7 +296,7 @@ impl Default for Config {
}
}

impl<'de> Deserialize<'de> for Config {
impl<'de> serde::Deserialize<'de> for Config {
fn deserialize<D: Deserializer<'de>>(de: D) -> std::result::Result<Self, D::Error> {
let raw = Value::deserialize(de)?;

Expand Down Expand Up @@ -588,7 +589,7 @@ impl HtmlConfig {

/// Configuration for how to render the print icon, print.html, and print.css.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
#[serde(rename_all = "kebab-case")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the print_config test fail because the page_break key is missing.

(Incidentally, this is logged... but tests don't enable logging. Adding the following at the beginning of the test resolves that:

env_logger::builder().is_test(true).try_init().unwrap();

)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ISSOtm, wow, thank you very much for debugging this! I wanted to fix the errors on the branch and this one made me scratch my head 😄

pub struct Print {
/// Whether print support is enabled.
pub enable: bool,
Expand Down Expand Up @@ -724,6 +725,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]
Expand Down Expand Up @@ -890,8 +892,6 @@ mod tests {
title = "mdBook Documentation"
description = "Create book from markdown files. Like Gitbook but implemented in Rust"
authors = ["Mathieu David"]
src = "./source"
[rust]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fails because this line was removed—edition should be in the rust table.

edition = "2021"
"#;

Expand Down
11 changes: 0 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@
#![deny(rust_2018_idioms)]
#![allow(clippy::comparison_chain)]

#[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;
Expand Down
1 change: 1 addition & 0 deletions src/preprocess/cmd.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 3 additions & 2 deletions src/preprocess/index.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/preprocess/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/preprocess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +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.
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/html_handlebars/helpers/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>;

Expand Down
1 change: 1 addition & 0 deletions src/renderer/html_handlebars/helpers/theme.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError};
use log::trace;

pub fn theme_option(
h: &Helper<'_, '_>,
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/html_handlebars/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// Creates all files required for search.
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/markdown_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/utils/fs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::errors::*;
use log::{debug, trace};
use std::convert::Into;
use std::fs::{self, File};
use std::io::Write;
Expand Down
5 changes: 3 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/utils/string.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use lazy_static::lazy_static;
use regex::Regex;
use std::ops::Bound::{Excluded, Included, Unbounded};
use std::ops::RangeBounds;
Expand Down