use std::path::PathBuf;
use mdbook_preprocessor::PreprocessorContext;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[serde(default)]
pub struct Config {
pub tracey_config: Option<PathBuf>,
pub repo_url: Option<String>,
pub style: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
tracey_config: None,
repo_url: None,
style: true,
}
}
}
impl Config {
pub fn from_context(ctx: &PreprocessorContext) -> anyhow::Result<Self> {
let mut cfg: Self = ctx.config.get("preprocessor.tracey")?.unwrap_or_default();
if let Some(p) = &mut cfg.tracey_config {
*p = ctx.root.join(&*p);
}
Ok(cfg)
}
}