fix(macros/c_api/header): Format doc comments in a c-like way

Formatting them with `/// [Comment]` is a rust convention, c uses `/**
[Comment] */`.
This commit is contained in:
Benedikt Peetz 2024-03-24 17:54:18 +01:00
parent cd5b0c9ee4
commit 17fd954e46
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
2 changed files with 10 additions and 5 deletions

View File

@ -111,8 +111,11 @@ pub fn generate(trixy: &CommandSpec, _config: &TrixyConfig) -> String {
}
fn attribute_to_doc_comment(attribute: &Attribute) -> String {
let Attribute::doc(doc_comment) = attribute;
format!("/// {}\n", doc_comment)
if let Attribute::doc(doc_comment) = attribute {
format!("/** {}\n*/", doc_comment)
} else {
"".to_owned()
}
}
fn named_type_to_c(named_type: &NamedType) -> TokenStream2 {

View File

@ -104,9 +104,11 @@ fn enumeration_to_header(enumeration: &Enumeration) -> String {
.map(doc_identifier_to_header)
.collect::<String>();
let states = if enumeration.states.is_empty() {
"/// This enum does not have variants on the rust side
/// to work around c limitiation with variant-less enums
/// we added a `__never` variant:
"/**
* This enum does not have variants on the rust side
* to work around c limitiation with variant-less enums
* we added a `__never` variant:
*/
__never,"
.to_owned()
} else {