Skip to content

Commit 02b6628

Browse files
committed
Finish move of config to mdbook-core
This updates everything for the move of config to mdbook-core. There will be followup commits that will be moving and refactoring the config. This simply moves it over unchanged.
1 parent 4ae5a53 commit 02b6628

File tree

15 files changed

+40
-37
lines changed

15 files changed

+40
-37
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ log = "0.4.27"
2626
mdbook-core = { path = "crates/mdbook-core" }
2727
pulldown-cmark = { version = "0.10.3", default-features = false, features = ["html"] } # Do not update, part of the public api.
2828
regex = "1.11.1"
29+
serde = { version = "1.0.219", features = ["derive"] }
30+
serde_json = "1.0.140"
2931
tempfile = "3.20.0"
3032
toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037
3133

@@ -61,8 +63,8 @@ memchr = "2.5.0"
6163
opener = "0.8.1"
6264
pulldown-cmark.workspace = true
6365
regex.workspace = true
64-
serde = { version = "1.0.163", features = ["derive"] }
65-
serde_json = "1.0.96"
66+
serde.workspace = true
67+
serde_json.workspace = true
6668
sha2 = "0.10.8"
6769
shlex = "1.3.0"
6870
tempfile.workspace = true

crates/mdbook-core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ anyhow.workspace = true
1212
log.workspace = true
1313
pulldown-cmark.workspace = true
1414
regex.workspace = true
15+
serde.workspace = true
16+
serde_json.workspace = true
1517
toml.workspace = true
1618

1719
[dev-dependencies]

crates/mdbook-core/src/config.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! # use anyhow::Result;
1313
//! use std::path::PathBuf;
1414
//! use std::str::FromStr;
15-
//! use mdbook::Config;
15+
//! use mdbook_core::config::Config;
1616
//! use toml::Value;
1717
//!
1818
//! # fn run() -> Result<()> {
@@ -47,11 +47,10 @@
4747
//! # run().unwrap()
4848
//! ```
4949
50-
use crate::utils::{self, toml_ext::TomlExt};
50+
use crate::utils::log_backtrace;
51+
use crate::utils::toml_ext::TomlExt;
5152
use anyhow::{Context, Error, Result, bail};
5253
use log::{debug, trace, warn};
53-
use mdbook_core::utils::log_backtrace;
54-
use mdbook_core::utils::toml_ext::TomlExt;
5554
use serde::{Deserialize, Deserializer, Serialize, Serializer};
5655
use std::collections::HashMap;
5756
use std::env;
@@ -814,7 +813,7 @@ impl<'de, T> Updateable<'de> for T where T: Serialize + Deserialize<'de> {}
814813
#[cfg(test)]
815814
mod tests {
816815
use super::*;
817-
use mdbook_core::utils::fs::get_404_output_file;
816+
use crate::utils::fs::get_404_output_file;
818817
use serde_json::json;
819818

820819
const COMPLEX_CONFIG: &str = r#"

crates/mdbook-core/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
/// compatibility checks.
77
pub const MDBOOK_VERSION: &str = env!("CARGO_PKG_VERSION");
88

9+
pub mod config;
10+
pub mod utils;
11+
912
/// The error types used in mdbook.
1013
pub mod errors {
1114
pub use anyhow::{Error, Result};
1215
}
13-
pub mod utils;

src/book/book.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use std::io::{Read, Write};
55
use std::path::{Path, PathBuf};
66

77
use super::summary::{Link, SectionNumber, Summary, SummaryItem, parse_summary};
8-
use crate::config::BuildConfig;
98
use anyhow::{Context, Result};
109
use log::debug;
10+
use mdbook_core::config::BuildConfig;
1111
use mdbook_core::utils::bracket_escape;
1212
use serde::{Deserialize, Serialize};
1313

src/book/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::io::Write;
33
use std::path::PathBuf;
44

55
use super::MDBook;
6-
use crate::config::Config;
76
use crate::theme;
87
use anyhow::{Context, Result};
98
use log::{debug, error, info, trace};
9+
use mdbook_core::config::Config;
1010
use mdbook_core::utils::fs::write_file;
1111

1212
/// A helper for setting up a new book and its directory structure.

src/book/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub use self::summary::{Link, SectionNumber, Summary, SummaryItem, parse_summary
1515

1616
use anyhow::{Context, Error, Result, bail};
1717
use log::{debug, error, info, log_enabled, trace, warn};
18+
use mdbook_core::config::{Config, RustEdition};
19+
use mdbook_core::utils;
1820
use std::ffi::OsString;
1921
use std::io::{IsTerminal, Write};
2022
use std::path::{Path, PathBuf};
@@ -27,9 +29,6 @@ use crate::preprocess::{
2729
CmdPreprocessor, IndexPreprocessor, LinkPreprocessor, Preprocessor, PreprocessorContext,
2830
};
2931
use crate::renderer::{CmdRenderer, HtmlHandlebars, MarkdownRenderer, RenderContext, Renderer};
30-
use mdbook_core::utils;
31-
32-
use crate::config::{Config, RustEdition};
3332

3433
/// The object used to manage and build a book.
3534
pub struct MDBook {

src/cmd/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::get_book_dir;
22
use anyhow::Result;
33
use clap::{ArgMatches, Command as ClapCommand, arg};
44
use mdbook::MDBook;
5-
use mdbook::config;
5+
use mdbook_core::config;
66
use std::io;
77
use std::io::Write;
88
use std::process::Command;

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//!
3030
//! ```rust,no_run
3131
//! use mdbook::MDBook;
32-
//! use mdbook::config::Config;
32+
//! use mdbook_core::config::Config;
3333
//!
3434
//! let root_dir = "/path/to/book/root";
3535
//!
@@ -78,17 +78,16 @@
7878
//! [user guide]: https://rust-lang.github.io/mdBook/
7979
//! [`RenderContext`]: renderer::RenderContext
8080
//! [relevant chapter]: https://rust-lang.github.io/mdBook/for_developers/backends.html
81-
//! [`Config`]: config::Config
81+
//! [`Config`]: mdbook_core::config::Config
8282
8383
pub mod book;
84-
pub mod config;
8584
pub mod preprocess;
8685
pub mod renderer;
8786
#[path = "front-end/mod.rs"]
8887
pub mod theme;
8988

9089
pub use crate::book::BookItem;
9190
pub use crate::book::MDBook;
92-
pub use crate::config::Config;
9391
pub use crate::renderer::Renderer;
9492
pub use mdbook_core::MDBOOK_VERSION;
93+
pub use mdbook_core::config::Config;

0 commit comments

Comments
 (0)