use crate::parser::command_spec::Attribute;
impl Attribute {
pub fn to_auxiliary_c(&self) -> String {
if let Attribute::doc(doc_comment) = self {
format!("/**\n*{}\n*/", doc_comment)
} else {
"".to_owned()
}
}
pub fn to_auxiliary_c_merged(attributes: &[Self]) -> String {
let doc_comments = attributes
.iter()
.map(|attr| {
if let Attribute::doc(doc_comment) = attr {
if doc_comment.is_empty() {
"*\n".to_owned()
} else {
doc_comment
.lines()
.map(|line| format!("*{}\n", line))
.collect::<String>()
}
} else {
attr.to_auxiliary_c()
}
})
.collect::<String>();
if !attributes.is_empty() {
format!("/**\n{}*/", doc_comments)
} else {
"".to_owned()
}
}
}