pub fn load_config(ctx: &PreprocessorContext) -> Result<GitInfoConfig, Error>Expand description
Load and deserialize the [preprocessor.gitinfo] table from book.toml.
This function reads configuration values from the mdBook configuration
tree and deserializes them into GitInfoConfig.
If the [preprocessor.gitinfo] section is missing, default values are
returned. Invalid configuration values result in an error.
§Arguments
ctx— ThePreprocessorContextprovided bymdbook-preprocessor, containing the parsedbook.tomlconfiguration.
§Errors
Returns an Error if the configuration section exists but cannot be
deserialized into GitInfoConfig.
§Examples
use mdbook_preprocessor::PreprocessorContext;
use mdbook_gitinfo::config::load_config;
fn example(ctx: &PreprocessorContext) -> Result<(), mdbook_preprocessor::errors::Error> {
let cfg = load_config(ctx)?;
if let Some(template) = cfg.template {
println!("Using template: {}", template);
}
Ok(())
}