[][src]Module mdbook::config

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.

Examples

use std::path::PathBuf;
use std::str::FromStr;
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: Option<PathBuf> = cfg.get_deserialized_opt("output.html.theme")?;
assert_eq!(got, Some(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.

Fold

Configuration for how to fold chapters of sidebar.

HtmlConfig

Configuration for the HTML renderer.

Playground

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

RustConfig

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

Search

Configuration of the search functionality of the HTML renderer.

Enums

RustEdition

Rust edition to use for the code.