From 4a655ff2a38b9ebd505a04f7e6414ea04a8d8f9d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 21 Jul 2025 10:57:23 -0700 Subject: [PATCH] Add mdbook-core This is intended as a shared, internal library that will be used by other mdbook crates. The intention is that those crates will either directly use, or reexport items from this crate. Initially this includes MDBOOK_VERSION, which will get reexported from the preprocessor and renderer crates. --- Cargo.lock | 7 ++++++- Cargo.toml | 10 +++++++++- crates/mdbook-core/Cargo.toml | 13 +++++++++++++ crates/mdbook-core/src/lib.rs | 7 +++++++ src/lib.rs | 7 +------ 5 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 crates/mdbook-core/Cargo.toml create mode 100644 crates/mdbook-core/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index dc7e85eb..c44924f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -1270,6 +1270,7 @@ dependencies = [ "hex", "ignore", "log", + "mdbook-core", "memchr", "notify", "notify-debouncer-mini", @@ -1293,6 +1294,10 @@ dependencies = [ "walkdir", ] +[[package]] +name = "mdbook-core" +version = "0.5.0-alpha.1" + [[package]] name = "mdbook-remove-emphasis" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 4e2f2251..cf8e05fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,9 @@ [workspace] -members = [".", "examples/remove-emphasis/mdbook-remove-emphasis"] +members = [ + ".", + "crates/*", + "examples/remove-emphasis/mdbook-remove-emphasis", +] [workspace.lints.clippy] all = { level = "allow", priority = -2 } @@ -16,6 +20,9 @@ license = "MPL-2.0" repository = "https://github.com/rust-lang/mdBook" rust-version = "1.85.0" # Keep in sync with installation.md and .github/workflows/main.yml +[workspace.dependencies] +mdbook-core = { path = "crates/mdbook-core" } + [package] name = "mdbook" version = "0.4.52" @@ -43,6 +50,7 @@ env_logger = "0.11.1" handlebars = "6.0" hex = "0.4.3" log = "0.4.17" +mdbook-core.workspace = true memchr = "2.5.0" opener = "0.8.1" pulldown-cmark = { version = "0.10.0", default-features = false, features = ["html"] } # Do not update, part of the public api. diff --git a/crates/mdbook-core/Cargo.toml b/crates/mdbook-core/Cargo.toml new file mode 100644 index 00000000..b8888e9c --- /dev/null +++ b/crates/mdbook-core/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "mdbook-core" +version = "0.5.0-alpha.1" +description = "The base support library for mdbook, intended for internal use only" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true + +[dependencies] + +[lints] +workspace = true diff --git a/crates/mdbook-core/src/lib.rs b/crates/mdbook-core/src/lib.rs new file mode 100644 index 00000000..152102dd --- /dev/null +++ b/crates/mdbook-core/src/lib.rs @@ -0,0 +1,7 @@ +//! The base support library for mdbook, intended for internal use only. + +/// The current version of `mdbook`. +/// +/// This is provided as a way for custom preprocessors and renderers to do +/// compatibility checks. +pub const MDBOOK_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src/lib.rs b/src/lib.rs index 93c41769..73195279 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,16 +88,11 @@ pub mod renderer; pub mod theme; pub mod utils; -/// The current version of `mdbook`. -/// -/// This is provided as a way for custom preprocessors and renderers to do -/// compatibility checks. -pub const MDBOOK_VERSION: &str = env!("CARGO_PKG_VERSION"); - pub use crate::book::BookItem; pub use crate::book::MDBook; pub use crate::config::Config; pub use crate::renderer::Renderer; +pub use mdbook_core::MDBOOK_VERSION; /// The error types used through out this crate. pub mod errors {