Module mdbook::config[][src]

Mdbook's configuration system.

The main entrypoint of the config module is the Config struct. This acts essentially as a bag of configuration information, with a couple pre-determined tables (BookConfig and BuildConfig) as well as support for arbitrary data which is exposed to plugins and alternate backends.

Examples

use std::path::PathBuf;
use mdbook::Config;
use toml::Value;

let src = r#"
[book]
title = "My Book"
authors = ["Michael-F-Bryan"]

[build]
src = "out"

[other-table.foo]
bar = 123
"#;

// load the `Config` from a toml string
let mut cfg = Config::from_str(src)?;

// retrieve a nested value
let bar = cfg.get("other-table.foo.bar").cloned();
assert_eq!(bar, Some(Value::Integer(123)));

// Set the `output.html.theme` directory
assert!(cfg.get("output.html").is_none());
cfg.set("output.html.theme", "./themes");

// then load it again, automatically deserializing to a `PathBuf`.
let got: PathBuf = cfg.get_deserialized("output.html.theme")?;
assert_eq!(got, PathBuf::from("./themes"));

Structs

BookConfig

Configuration options which are specific to the book and required for loading it from disk.

BuildConfig

Configuration for the build procedure.

Config

The overall configuration object for MDBook, essentially an in-memory representation of book.toml.

HtmlConfig

Configuration for the HTML renderer.

Playpen

Configuration for tweaking how the the HTML renderer handles the playpen.

Search

Configuration of the search functionality of the HTML renderer.