use std::collections::BTreeMap;
#[derive(Clone, Debug)]
pub struct CodeGeneratorConfig {
pub(crate) module_name: String,
pub(crate) external_definitions: ExternalDefinitions,
pub(crate) comments: DocComments,
}
pub type ExternalDefinitions =
std::collections::BTreeMap< String, Vec<String>>;
pub type DocComments =
std::collections::BTreeMap< Vec<String>, String>;
impl CodeGeneratorConfig {
pub fn new(module_name: String) -> Self {
Self {
module_name,
external_definitions: BTreeMap::new(),
comments: BTreeMap::new(),
}
}
pub fn with_external_definitions(mut self, external_definitions: ExternalDefinitions) -> Self {
self.external_definitions = external_definitions;
self
}
pub fn with_comments(mut self, mut comments: DocComments) -> Self {
for comment in comments.values_mut() {
*comment = format!("{}\n", comment.trim());
}
self.comments = comments;
self
}
}