[−][src]Struct mdbook::config::Config
The overall configuration object for MDBook, essentially an in-memory
representation of book.toml.
Fields
book: BookConfigMetadata about the book.
build: BuildConfigInformation about the build environment.
Methods
impl Config[src]
pub fn from_disk<P: AsRef<Path>>(config_file: P) -> Result<Config>[src]
Load the configuration file from disk.
pub fn update_from_env(&mut self)[src]
Updates the Config from the available environment variables.
Variables starting with MDBOOK_ are used for configuration. The key is
created by removing the MDBOOK_ prefix and turning the resulting
string into kebab-case. Double underscores (__) separate nested
keys, while a single underscore (_) is replaced with a dash (-).
For example:
MDBOOK_foo->fooMDBOOK_FOO->fooMDBOOK_FOO__BAR->foo.barMDBOOK_FOO_BAR->foo-barMDBOOK_FOO_bar__baz->foo-bar.baz
So by setting the MDBOOK_BOOK__TITLE environment variable you can
override the book's title without needing to touch your book.toml.
Note: To facilitate setting more complex config items, the value of an environment variable is first parsed as JSON, falling back to a string if the parse fails.
This means, if you so desired, you could override all book metadata when building the book with something like
$ export MDBOOK_BOOK="{'title': 'My Awesome Book', authors: ['Michael-F-Bryan']}" $ mdbook build
The latter case may be useful in situations where mdbook is invoked
from a script or CI, where it sometimes isn't possible to update the
book.toml before building.
pub fn get(&self, key: &str) -> Option<&Value>[src]
Fetch an arbitrary item from the Config as a toml::Value.
You can use dotted indices to access nested items (e.g.
output.html.playpen will fetch the "playpen" out of the html output
table).
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>[src]
Fetch a value from the Config so you can mutate it.
pub fn get_deserialized<'de, T: Deserialize<'de>, S: AsRef<str>>(
&self,
name: S
) -> Result<T>[src]
&self,
name: S
) -> Result<T>
use get_deserialized_opt instead
Deprecated, use get_deserialized_opt instead.
pub fn get_deserialized_opt<'de, T: Deserialize<'de>, S: AsRef<str>>(
&self,
name: S
) -> Result<Option<T>>[src]
&self,
name: S
) -> Result<Option<T>>
Convenience function to fetch a value from the config and deserialize it into some arbitrary type.
pub fn set<S: Serialize, I: AsRef<str>>(
&mut self,
index: I,
value: S
) -> Result<()>[src]
&mut self,
index: I,
value: S
) -> Result<()>
Set a config key, clobbering any existing values along the way.
The only way this can fail is if we can't serialize value into a
toml::Value.
pub fn get_renderer<I: AsRef<str>>(&self, index: I) -> Option<&Table>[src]
Get the table associated with a particular renderer.
pub fn get_preprocessor<I: AsRef<str>>(&self, index: I) -> Option<&Table>[src]
Get the table associated with a particular preprocessor.
Trait Implementations
impl Clone for Config[src]
impl Debug for Config[src]
impl Default for Config[src]
impl<'de> Deserialize<'de> for Config[src]
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>[src]
impl FromStr for Config[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<Self>[src]
Load a Config from some string.
impl PartialEq<Config> for Config[src]
impl Serialize for Config[src]
impl StructuralPartialEq for Config[src]
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> CloneAny for T where
T: Clone + Any, [src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send, [src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync, [src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync, [src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug, [src]
T: Any + Debug,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Typeable for T where
T: Any, [src]
T: Any,
impl<T> UnsafeAny for T where
T: Any, [src]
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src]
V: MultiLane<T>,