Remove 'curly_quotes' key from the json config
This commit is contained in:
parent
d252dc82d6
commit
26fc980ffb
|
@ -113,7 +113,7 @@ impl BookConfig {
|
||||||
htmlconfig.fill_from_tomlconfig(root, tomlhtmlconfig);
|
htmlconfig.fill_from_tomlconfig(root, tomlhtmlconfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,12 +160,6 @@ impl BookConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(curly_quotes) = jsonconfig.curly_quotes {
|
|
||||||
if let Some(htmlconfig) = self.get_mut_html_config() {
|
|
||||||
htmlconfig.set_curly_quotes(curly_quotes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,16 +171,16 @@ impl BookConfig {
|
||||||
pub fn get_root(&self) -> &Path {
|
pub fn get_root(&self) -> &Path {
|
||||||
&self.root
|
&self.root
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_source<T: Into<PathBuf>>(&mut self, source: T) -> &mut Self {
|
pub fn set_source<T: Into<PathBuf>>(&mut self, source: T) -> &mut Self {
|
||||||
let mut source = source.into();
|
let mut source = source.into();
|
||||||
|
|
||||||
// If the source path is relative, start with the root path
|
// If the source path is relative, start with the root path
|
||||||
if source.is_relative() {
|
if source.is_relative() {
|
||||||
source = self.root.join(source);
|
source = self.root.join(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.source = source;
|
self.source = source;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ pub struct JsonConfig {
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
|
|
||||||
pub theme_path: Option<PathBuf>,
|
pub theme_path: Option<PathBuf>,
|
||||||
pub curly_quotes: Option<bool>,
|
|
||||||
pub google_analytics: Option<String>,
|
pub google_analytics: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +24,9 @@ pub struct JsonConfig {
|
||||||
/// # use std::path::PathBuf;
|
/// # use std::path::PathBuf;
|
||||||
/// let json = r#"{
|
/// let json = r#"{
|
||||||
/// "title": "Some title",
|
/// "title": "Some title",
|
||||||
/// "dest": "htmlbook"
|
/// "dest": "htmlbook"
|
||||||
/// }"#;
|
/// }"#;
|
||||||
///
|
///
|
||||||
/// let config = JsonConfig::from_json(&json).expect("Should parse correctly");
|
/// let config = JsonConfig::from_json(&json).expect("Should parse correctly");
|
||||||
/// assert_eq!(config.title, Some(String::from("Some title")));
|
/// assert_eq!(config.title, Some(String::from("Some title")));
|
||||||
/// assert_eq!(config.dest, Some(PathBuf::from("htmlbook")));
|
/// assert_eq!(config.dest, Some(PathBuf::from("htmlbook")));
|
||||||
|
@ -36,9 +35,7 @@ impl JsonConfig {
|
||||||
pub fn from_json(input: &str) -> Result<Self, String> {
|
pub fn from_json(input: &str) -> Result<Self, String> {
|
||||||
let config: JsonConfig = serde_json::from_str(input)
|
let config: JsonConfig = serde_json::from_str(input)
|
||||||
.map_err(|e| format!("Could not parse JSON: {}", e))?;
|
.map_err(|e| format!("Could not parse JSON: {}", e))?;
|
||||||
|
|
||||||
return Ok(config);
|
return Ok(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,18 +85,3 @@ fn from_json_output_html_theme() {
|
||||||
|
|
||||||
assert_eq!(htmlconfig.get_theme().expect("the theme key was provided"), &PathBuf::from("root/theme"));
|
assert_eq!(htmlconfig.get_theme().expect("the theme key was provided"), &PathBuf::from("root/theme"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the `curly_quotes` key is correctly parsed in the JSON config
|
|
||||||
#[test]
|
|
||||||
fn from_json_output_html_curly_quotes() {
|
|
||||||
let json = r#"{
|
|
||||||
"curly_quotes": true
|
|
||||||
}"#;
|
|
||||||
|
|
||||||
let parsed = JsonConfig::from_json(&json).expect("This should parse");
|
|
||||||
let config = BookConfig::from_jsonconfig("root", parsed);
|
|
||||||
|
|
||||||
let htmlconfig = config.get_html_config().expect("There should be an HtmlConfig");
|
|
||||||
|
|
||||||
assert_eq!(htmlconfig.get_curly_quotes(), true);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue