tfschema_bindgen/
config.rs1use std::collections::BTreeMap;
5
6#[derive(Clone, Debug)]
8pub struct CodeGeneratorConfig {
9 pub(crate) module_name: String,
10 pub(crate) external_definitions: ExternalDefinitions,
11 pub(crate) comments: DocComments,
12}
13
14pub type ExternalDefinitions =
16 std::collections::BTreeMap<String, Vec<String>>;
17
18pub type DocComments =
20 std::collections::BTreeMap<Vec<String>, String>;
21
22impl CodeGeneratorConfig {
23 pub fn new(module_name: String) -> Self {
25 Self {
26 module_name,
27 external_definitions: BTreeMap::new(),
28 comments: BTreeMap::new(),
29 }
30 }
31
32 pub fn with_external_definitions(mut self, external_definitions: ExternalDefinitions) -> Self {
34 self.external_definitions = external_definitions;
35 self
36 }
37
38 pub fn with_comments(mut self, mut comments: DocComments) -> Self {
40 for comment in comments.values_mut() {
42 *comment = format!("{}\n", comment.trim());
43 }
44 self.comments = comments;
45 self
46 }
47}