use serde_derive::{Deserialize, Serialize}; use structopt::StructOpt; use std::collections::{HashMap, HashSet}; #[derive(Debug, Clone, Serialize)] pub(crate) struct Config { /// Tells us in which language, which entity types should inline which children entity type in /// their documentation. /// /// e.g. in C++, classes should inline their children methods documentation. pub(crate) inlines: HashMap>>, } impl Config { pub(crate) fn from_merge(_cli: ProvidedConfig, conf: ProvidedConfig) -> Self { Self { inlines: conf.inlines.unwrap_or_else(default_inlines), } } } fn default_inlines() -> HashMap>> { let mut clang = HashMap::new(); let mut clang_inline_children = HashSet::new(); // TODO: this is not great: no differences between variable/field for children, but differences // as a parent... clang_inline_children.insert(String::from("variable")); //classes.insert(String::from("field")); clang_inline_children.insert(String::from("function")); //classes.insert(String::from("method")); clang.insert(String::from("struct"), clang_inline_children.clone()); clang.insert(String::from("class"), clang_inline_children.clone()); clang.insert(String::from("namespace"), clang_inline_children); let mut inlines = HashMap::new(); inlines.insert(String::from("clang"), clang); inlines } impl Default for Config { fn default() -> Self { Config::from_merge(ProvidedConfig::default(), ProvidedConfig::default()) } } #[derive(Debug, Clone, Default, StructOpt, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub(crate) struct ProvidedConfig { #[structopt(skip)] pub(crate) inlines: Option>>>, }