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.
This commit is contained in:
parent
4ae5a53791
commit
02b6628048
15 changed files with 40 additions and 37 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1302,6 +1302,8 @@ dependencies = [
|
|||
"log",
|
||||
"pulldown-cmark 0.10.3",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"toml",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ log = "0.4.27"
|
|||
mdbook-core = { path = "crates/mdbook-core" }
|
||||
pulldown-cmark = { version = "0.10.3", default-features = false, features = ["html"] } # Do not update, part of the public api.
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.140"
|
||||
tempfile = "3.20.0"
|
||||
toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037
|
||||
|
||||
|
|
@ -61,8 +63,8 @@ memchr = "2.5.0"
|
|||
opener = "0.8.1"
|
||||
pulldown-cmark.workspace = true
|
||||
regex.workspace = true
|
||||
serde = { version = "1.0.163", features = ["derive"] }
|
||||
serde_json = "1.0.96"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
sha2 = "0.10.8"
|
||||
shlex = "1.3.0"
|
||||
tempfile.workspace = true
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ anyhow.workspace = true
|
|||
log.workspace = true
|
||||
pulldown-cmark.workspace = true
|
||||
regex.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
toml.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
//! # use anyhow::Result;
|
||||
//! use std::path::PathBuf;
|
||||
//! use std::str::FromStr;
|
||||
//! use mdbook::Config;
|
||||
//! use mdbook_core::config::Config;
|
||||
//! use toml::Value;
|
||||
//!
|
||||
//! # fn run() -> Result<()> {
|
||||
|
|
@ -47,11 +47,10 @@
|
|||
//! # run().unwrap()
|
||||
//! ```
|
||||
|
||||
use crate::utils::{self, toml_ext::TomlExt};
|
||||
use crate::utils::log_backtrace;
|
||||
use crate::utils::toml_ext::TomlExt;
|
||||
use anyhow::{Context, Error, Result, bail};
|
||||
use log::{debug, trace, warn};
|
||||
use mdbook_core::utils::log_backtrace;
|
||||
use mdbook_core::utils::toml_ext::TomlExt;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
|
|
@ -814,7 +813,7 @@ impl<'de, T> Updateable<'de> for T where T: Serialize + Deserialize<'de> {}
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use mdbook_core::utils::fs::get_404_output_file;
|
||||
use crate::utils::fs::get_404_output_file;
|
||||
use serde_json::json;
|
||||
|
||||
const COMPLEX_CONFIG: &str = r#"
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@
|
|||
/// compatibility checks.
|
||||
pub const MDBOOK_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub mod config;
|
||||
pub mod utils;
|
||||
|
||||
/// The error types used in mdbook.
|
||||
pub mod errors {
|
||||
pub use anyhow::{Error, Result};
|
||||
}
|
||||
pub mod utils;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use std::io::{Read, Write};
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use super::summary::{Link, SectionNumber, Summary, SummaryItem, parse_summary};
|
||||
use crate::config::BuildConfig;
|
||||
use anyhow::{Context, Result};
|
||||
use log::debug;
|
||||
use mdbook_core::config::BuildConfig;
|
||||
use mdbook_core::utils::bracket_escape;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use std::io::Write;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use super::MDBook;
|
||||
use crate::config::Config;
|
||||
use crate::theme;
|
||||
use anyhow::{Context, Result};
|
||||
use log::{debug, error, info, trace};
|
||||
use mdbook_core::config::Config;
|
||||
use mdbook_core::utils::fs::write_file;
|
||||
|
||||
/// A helper for setting up a new book and its directory structure.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ pub use self::summary::{Link, SectionNumber, Summary, SummaryItem, parse_summary
|
|||
|
||||
use anyhow::{Context, Error, Result, bail};
|
||||
use log::{debug, error, info, log_enabled, trace, warn};
|
||||
use mdbook_core::config::{Config, RustEdition};
|
||||
use mdbook_core::utils;
|
||||
use std::ffi::OsString;
|
||||
use std::io::{IsTerminal, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
@ -27,9 +29,6 @@ use crate::preprocess::{
|
|||
CmdPreprocessor, IndexPreprocessor, LinkPreprocessor, Preprocessor, PreprocessorContext,
|
||||
};
|
||||
use crate::renderer::{CmdRenderer, HtmlHandlebars, MarkdownRenderer, RenderContext, Renderer};
|
||||
use mdbook_core::utils;
|
||||
|
||||
use crate::config::{Config, RustEdition};
|
||||
|
||||
/// The object used to manage and build a book.
|
||||
pub struct MDBook {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::get_book_dir;
|
|||
use anyhow::Result;
|
||||
use clap::{ArgMatches, Command as ClapCommand, arg};
|
||||
use mdbook::MDBook;
|
||||
use mdbook::config;
|
||||
use mdbook_core::config;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
//!
|
||||
//! ```rust,no_run
|
||||
//! use mdbook::MDBook;
|
||||
//! use mdbook::config::Config;
|
||||
//! use mdbook_core::config::Config;
|
||||
//!
|
||||
//! let root_dir = "/path/to/book/root";
|
||||
//!
|
||||
|
|
@ -78,10 +78,9 @@
|
|||
//! [user guide]: https://rust-lang.github.io/mdBook/
|
||||
//! [`RenderContext`]: renderer::RenderContext
|
||||
//! [relevant chapter]: https://rust-lang.github.io/mdBook/for_developers/backends.html
|
||||
//! [`Config`]: config::Config
|
||||
//! [`Config`]: mdbook_core::config::Config
|
||||
|
||||
pub mod book;
|
||||
pub mod config;
|
||||
pub mod preprocess;
|
||||
pub mod renderer;
|
||||
#[path = "front-end/mod.rs"]
|
||||
|
|
@ -89,6 +88,6 @@ pub mod theme;
|
|||
|
||||
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;
|
||||
pub use mdbook_core::config::Config;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
//! Book preprocessing.
|
||||
|
||||
use crate::book::Book;
|
||||
use anyhow::Result;
|
||||
use mdbook_core::config::Config;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub use self::cmd::CmdPreprocessor;
|
||||
pub use self::index::IndexPreprocessor;
|
||||
pub use self::links::LinkPreprocessor;
|
||||
|
|
@ -8,15 +16,6 @@ mod cmd;
|
|||
mod index;
|
||||
mod links;
|
||||
|
||||
use crate::book::Book;
|
||||
use crate::config::Config;
|
||||
use anyhow::Result;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Extra information for a `Preprocessor` to give them more context when
|
||||
/// processing a book.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
use crate::book::{Book, BookItem};
|
||||
use crate::config::{BookConfig, Code, Config, HtmlConfig, Playground, RustEdition};
|
||||
use crate::renderer::html_handlebars::StaticFiles;
|
||||
use crate::renderer::html_handlebars::helpers;
|
||||
use crate::renderer::{RenderContext, Renderer};
|
||||
use crate::theme::{self, Theme};
|
||||
use mdbook_core::utils;
|
||||
use mdbook_core::utils::fs::get_404_output_file;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -17,6 +14,9 @@ use std::sync::LazyLock;
|
|||
use anyhow::{Context, Result, bail};
|
||||
use handlebars::Handlebars;
|
||||
use log::{debug, info, trace, warn};
|
||||
use mdbook_core::config::{BookConfig, Code, Config, HtmlConfig, Playground, RustEdition};
|
||||
use mdbook_core::utils;
|
||||
use mdbook_core::utils::fs::get_404_output_file;
|
||||
use regex::{Captures, Regex};
|
||||
use serde_json::json;
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ impl Renderer for HtmlHandlebars {
|
|||
// Render search index
|
||||
#[cfg(feature = "search")]
|
||||
{
|
||||
let default = crate::config::Search::default();
|
||||
let default = mdbook_core::config::Search::default();
|
||||
let search = html_config.search.as_ref().unwrap_or(&default);
|
||||
if search.enable {
|
||||
super::search::create_files(&search, &mut static_files, &book)?;
|
||||
|
|
@ -1008,9 +1008,8 @@ fn collect_redirects_for_path(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::config::TextDirection;
|
||||
|
||||
use super::*;
|
||||
use mdbook_core::config::TextDirection;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ use std::sync::LazyLock;
|
|||
use anyhow::{Context, Result, bail};
|
||||
use elasticlunr::{Index, IndexBuilder};
|
||||
use log::{debug, warn};
|
||||
use mdbook_core::config::{Search, SearchChapterSettings};
|
||||
use mdbook_core::utils;
|
||||
use pulldown_cmark::*;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::book::{Book, BookItem, Chapter};
|
||||
use crate::config::{Search, SearchChapterSettings};
|
||||
use crate::renderer::html_handlebars::StaticFiles;
|
||||
use crate::theme::searcher;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use log::{debug, warn};
|
||||
use mdbook_core::config::HtmlConfig;
|
||||
use mdbook_core::utils;
|
||||
|
||||
use crate::config::HtmlConfig;
|
||||
use crate::renderer::html_handlebars::helpers::resources::ResourceHelper;
|
||||
use crate::theme::{self, Theme, playground_editor};
|
||||
|
||||
|
|
@ -300,8 +300,8 @@ impl StaticFiles {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::config::HtmlConfig;
|
||||
use crate::theme::Theme;
|
||||
use mdbook_core::config::HtmlConfig;
|
||||
use mdbook_core::utils::fs::write_file;
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
//! [RenderContext]: struct.RenderContext.html
|
||||
|
||||
use crate::book::Book;
|
||||
use crate::config::Config;
|
||||
use anyhow::{Context, Result, bail};
|
||||
use log::{error, info, trace, warn};
|
||||
use mdbook_core::config::Config;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shlex::Shlex;
|
||||
use std::collections::HashMap;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue