Changed to the new config types

This commit is contained in:
Michael Bryan 2017-09-30 21:04:05 +08:00
parent 1d22a9a040
commit 8d7970b32d
No known key found for this signature in database
GPG key ID: E9C602B0D9A998DC

View file

@ -7,17 +7,17 @@ use serde::Deserialize;
use errors::*; use errors::*;
pub mod bookconfig; // pub mod bookconfig;
pub mod htmlconfig; // pub mod htmlconfig;
pub mod playpenconfig; // pub mod playpenconfig;
pub mod tomlconfig; // pub mod tomlconfig;
pub mod jsonconfig; // pub mod jsonconfig;
// Re-export the config structs // Re-export the config structs
pub use self::bookconfig::BookConfig; // pub use self::bookconfig::BookConfig;
pub use self::htmlconfig::HtmlConfig; // pub use self::htmlconfig::HtmlConfig;
pub use self::playpenconfig::PlaypenConfig; // pub use self::playpenconfig::PlaypenConfig;
pub use self::tomlconfig::TomlConfig; // pub use self::tomlconfig::TomlConfig;
/// The overall configuration object for MDBook. /// The overall configuration object for MDBook.
@ -25,7 +25,7 @@ pub use self::tomlconfig::TomlConfig;
#[serde(default)] #[serde(default)]
pub struct Config { pub struct Config {
/// Metadata about the book. /// Metadata about the book.
pub book: BookConfig_, pub book: BookConfig,
/// Arbitrary information which renderers can use during the rendering /// Arbitrary information which renderers can use during the rendering
/// stage. /// stage.
pub output: BTreeMap<String, Value>, pub output: BTreeMap<String, Value>,
@ -58,7 +58,7 @@ impl Config {
/// ///
/// This is for compatibility only. It will be removed completely once the /// This is for compatibility only. It will be removed completely once the
/// rendering and plugin system is established. /// rendering and plugin system is established.
pub fn html_config(&self) -> Option<HtmlConfig_> { pub fn html_config(&self) -> Option<HtmlConfig> {
self.try_get_output("html").ok() self.try_get_output("html").ok()
} }
@ -96,7 +96,7 @@ fn get_deserialized<'de, T: Deserialize<'de>, S: AsRef<str>>(name: S, table: &BT
/// loading it from disk. /// loading it from disk.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")] #[serde(default, rename_all = "kebab-case")]
pub struct BookConfig_ { pub struct BookConfig {
/// The book's title. /// The book's title.
pub title: Option<String>, pub title: Option<String>,
/// The book's authors. /// The book's authors.
@ -111,9 +111,9 @@ pub struct BookConfig_ {
pub multilingual: bool, pub multilingual: bool,
} }
impl Default for BookConfig_ { impl Default for BookConfig {
fn default() -> BookConfig_ { fn default() -> BookConfig {
BookConfig_ { BookConfig {
title: None, title: None,
authors: Vec::new(), authors: Vec::new(),
description: None, description: None,
@ -126,7 +126,7 @@ impl Default for BookConfig_ {
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")] #[serde(default, rename_all = "kebab-case")]
pub struct HtmlConfig_ { pub struct HtmlConfig {
pub theme: Option<PathBuf>, pub theme: Option<PathBuf>,
pub curly_quotes: bool, pub curly_quotes: bool,
pub mathjax_support: bool, pub mathjax_support: bool,