Expand description

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 alternative backends.


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

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

src = "out"

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
cfg.set("output.html.theme", "./themes");

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


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

Configuration for the build procedure.

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

Configuration for how to fold chapters of sidebar.

Configuration for the HTML renderer.

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

Configuration for how to render the print icon, print.html, and print.css.

Configuration for the Rust compiler(e.g., for playground)

Configuration of the search functionality of the HTML renderer.


Rust edition to use for the code.