use refix_dictionary::Dictionary;
use super::layout::{MAX_WIDTH, slice};
use crate::dialect::length_tags;
pub(super) fn emit_dialect(dictionary: &Dictionary) -> String {
let tags: Vec<String> = length_tags(dictionary)
.iter()
.map(|tag| format!("Tag({tag})"))
.collect();
let constant = if tags.is_empty() {
"pub const DIALECT: Dialect<'static> = Dialect::new();\n".to_owned()
} else {
slice(
"pub const DIALECT: Dialect<'static> = Dialect::new().with_extra_length_tags(",
&tags,
");",
MAX_WIDTH,
)
};
format!("/// The dialect of this dictionary.\n{constant}")
}