Finish moving built-in preprocessors to mdbook-driver
This commit is contained in:
parent
6aac696ee1
commit
f5fc54461a
12 changed files with 34 additions and 11 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -1267,6 +1267,7 @@ dependencies = [
|
|||
"ignore",
|
||||
"log",
|
||||
"mdbook-core",
|
||||
"mdbook-driver",
|
||||
"mdbook-html",
|
||||
"mdbook-markdown",
|
||||
"mdbook-preprocessor",
|
||||
|
|
@ -1310,6 +1311,15 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mdbook-driver"
|
||||
version = "0.5.0-alpha.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"log",
|
||||
"mdbook-core",
|
||||
"mdbook-preprocessor",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mdbook-html"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ regex = "1.11.1"
|
|||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.140"
|
||||
sha2 = "0.10.9"
|
||||
shlex = "1.3.0"
|
||||
tempfile = "3.20.0"
|
||||
toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ clap_complete = "4.3.2"
|
|||
env_logger = "0.11.1"
|
||||
log.workspace = true
|
||||
mdbook-core.workspace = true
|
||||
mdbook-driver.workspace = true
|
||||
mdbook-html.workspace = true
|
||||
mdbook-markdown.workspace = true
|
||||
mdbook-preprocessor.workspace = true
|
||||
|
|
@ -81,7 +83,7 @@ pulldown-cmark.workspace = true
|
|||
regex.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
shlex = "1.3.0"
|
||||
shlex.workspace = true
|
||||
tempfile.workspace = true
|
||||
toml.workspace = true
|
||||
topological-sort = "0.2.2"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
mdbook-core.workspace = true
|
||||
mdbook-preprocessor.workspace = true
|
||||
regex.workspace = true
|
||||
serde_json.workspace = true
|
||||
shlex.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::book::Book;
|
||||
use anyhow::{Context, Result, bail, ensure};
|
||||
use log::{debug, trace, warn};
|
||||
use mdbook_core::book::Book;
|
||||
use mdbook_preprocessor::{Preprocessor, PreprocessorContext};
|
||||
use shlex::Shlex;
|
||||
use std::io::{self, Write};
|
||||
|
|
@ -170,6 +170,7 @@ impl Preprocessor for CmdPreprocessor {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(false)] // Needs to wait for MDBook transfer
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::book::{Book, BookItem};
|
||||
use anyhow::Result;
|
||||
use log::warn;
|
||||
use mdbook_core::book::{Book, BookItem};
|
||||
use mdbook_preprocessor::{Preprocessor, PreprocessorContext};
|
||||
use regex::Regex;
|
||||
use std::{path::Path, sync::LazyLock};
|
||||
|
|
@ -11,7 +11,8 @@ use std::{path::Path, sync::LazyLock};
|
|||
pub struct IndexPreprocessor;
|
||||
|
||||
impl IndexPreprocessor {
|
||||
pub(crate) const NAME: &'static str = "index";
|
||||
/// Name of this preprocessor.
|
||||
pub const NAME: &'static str = "index";
|
||||
|
||||
/// Create a new `IndexPreprocessor`.
|
||||
pub fn new() -> Self {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::book::{Book, BookItem};
|
||||
use anyhow::{Context, Result};
|
||||
use log::{error, warn};
|
||||
use mdbook_core::book::{Book, BookItem};
|
||||
use mdbook_core::utils::{
|
||||
take_anchored_lines, take_lines, take_rustdoc_include_anchored_lines,
|
||||
take_rustdoc_include_lines,
|
||||
|
|
@ -29,7 +29,8 @@ const MAX_LINK_NESTED_DEPTH: usize = 10;
|
|||
pub struct LinkPreprocessor;
|
||||
|
||||
impl LinkPreprocessor {
|
||||
pub(crate) const NAME: &'static str = "links";
|
||||
/// Name of this preprocessor.
|
||||
pub const NAME: &'static str = "links";
|
||||
|
||||
/// Create a new `LinkPreprocessor`.
|
||||
pub fn new() -> Self {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//! Book preprocessing.
|
||||
//! Built-in preprocessors.
|
||||
|
||||
pub use self::cmd::CmdPreprocessor;
|
||||
pub use self::index::IndexPreprocessor;
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
//! High-level library for running mdBook.
|
||||
|
||||
pub mod builtin_preprocessors;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ mod init;
|
|||
|
||||
pub use self::book::load_book;
|
||||
pub use self::init::BookBuilder;
|
||||
use crate::preprocess::{CmdPreprocessor, IndexPreprocessor, LinkPreprocessor};
|
||||
use crate::renderer::{CmdRenderer, MarkdownRenderer};
|
||||
use anyhow::{Context, Error, Result, bail};
|
||||
use log::{debug, error, info, log_enabled, trace, warn};
|
||||
pub use mdbook_core::book::{Book, BookItem, BookItems, Chapter, SectionNumber};
|
||||
use mdbook_core::config::{Config, RustEdition};
|
||||
use mdbook_core::utils;
|
||||
use mdbook_driver::builtin_preprocessors::{CmdPreprocessor, IndexPreprocessor, LinkPreprocessor};
|
||||
use mdbook_html::HtmlHandlebars;
|
||||
use mdbook_preprocessor::{Preprocessor, PreprocessorContext};
|
||||
use mdbook_renderer::{RenderContext, Renderer};
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@
|
|||
//! [`Config`]: mdbook_core::config::Config
|
||||
|
||||
pub mod book;
|
||||
pub mod preprocess;
|
||||
pub mod renderer;
|
||||
|
||||
pub use crate::book::BookItem;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ fn recursive_include() {
|
|||
.run("build", |cmd| {
|
||||
cmd.expect_stderr(str![[r#"
|
||||
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
|
||||
[TIMESTAMP] [ERROR] (mdbook::preprocess::links): Stack depth exceeded in recursive.md. Check for cyclic includes
|
||||
[TIMESTAMP] [ERROR] (mdbook_driver::builtin_preprocessors::links): Stack depth exceeded in recursive.md. Check for cyclic includes
|
||||
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
|
||||
[TIMESTAMP] [INFO] (mdbook_html::html_handlebars::hbs_renderer): HTML book written to `[ROOT]/book`
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use mdbook::book::Book;
|
||||
use mdbook::preprocess::CmdPreprocessor;
|
||||
use mdbook_driver::builtin_preprocessors::CmdPreprocessor;
|
||||
use mdbook_preprocessor::{Preprocessor, PreprocessorContext};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue