summaryrefslogtreecommitdiffstats
path: root/src/generator/config.rs
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2019-12-18 20:56:53 +0100
committerMinijackson <minijackson@riseup.net>2019-12-18 20:56:53 +0100
commitde896baff7e97fac4dde79078c9a2fa1c652576b (patch)
tree512b67b91d64e51d63f7ac5ff925a5c96d9aaf3c /src/generator/config.rs
parent860b73f1644ecd6548ae403ec483625fb7b625ea (diff)
downloadposeidoc-de896baff7e97fac4dde79078c9a2fa1c652576b.tar.gz
poseidoc-de896baff7e97fac4dde79078c9a2fa1c652576b.zip
Big refactoring
- entities should be more coherent when parsing multiple files - well defined, language agnostic entity tree - each module has its own configuration - less dead code
Diffstat (limited to 'src/generator/config.rs')
-rw-r--r--src/generator/config.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/generator/config.rs b/src/generator/config.rs
new file mode 100644
index 0000000..43fee60
--- /dev/null
+++ b/src/generator/config.rs
@@ -0,0 +1,53 @@
1use serde_derive::{Deserialize, Serialize};
2use structopt::StructOpt;
3
4use std::collections::{HashMap, HashSet};
5
6#[derive(Debug, Clone, Serialize)]
7pub(crate) struct Config {
8 /// Tells us in which language, which entity types should inline which children entity type in
9 /// their documentation.
10 ///
11 /// e.g. in C++, classes should inline their children methods documentation.
12 pub(crate) inlines: HashMap<String, HashMap<String, HashSet<String>>>,
13}
14
15impl Config {
16 pub(crate) fn from_merge(_cli: ProvidedConfig, conf: ProvidedConfig) -> Self {
17 Self {
18 inlines: conf.inlines.unwrap_or_else(default_inlines),
19 }
20 }
21}
22
23fn default_inlines() -> HashMap<String, HashMap<String, HashSet<String>>> {
24 let mut clang = HashMap::new();
25 let mut clang_inline_children = HashSet::new();
26 // TODO: this is not great: no differences between variable/field for children, but differences
27 // as a parent...
28 clang_inline_children.insert(String::from("variable"));
29 //classes.insert(String::from("field"));
30 clang_inline_children.insert(String::from("function"));
31 //classes.insert(String::from("method"));
32 clang.insert(String::from("struct"), clang_inline_children.clone());
33 clang.insert(String::from("class"), clang_inline_children.clone());
34 clang.insert(String::from("namespace"), clang_inline_children);
35
36 let mut inlines = HashMap::new();
37 inlines.insert(String::from("clang"), clang);
38
39 inlines
40}
41
42impl Default for Config {
43 fn default() -> Self {
44 Config::from_merge(ProvidedConfig::default(), ProvidedConfig::default())
45 }
46}
47
48#[derive(Debug, Clone, Default, StructOpt, Deserialize, Serialize)]
49#[serde(rename_all = "kebab-case")]
50pub(crate) struct ProvidedConfig {
51 #[structopt(skip)]
52 pub(crate) inlines: Option<HashMap<String, HashMap<String, HashSet<String>>>>,
53}