From 17fd954e4671d8bf98abf923b7de2727e713e694 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 24 Mar 2024 17:54:18 +0100 Subject: [PATCH] fix(macros/c_api/header): Format doc comments in a c-like way Formatting them with `/// [Comment]` is a rust convention, c uses `/** [Comment] */`. --- trixy-macros/src/generate/c_api/header/mod.rs | 7 +++++-- trixy-macros/src/generate/c_api/header/pure_header.rs | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/trixy-macros/src/generate/c_api/header/mod.rs b/trixy-macros/src/generate/c_api/header/mod.rs index f763da0..4ff5d38 100644 --- a/trixy-macros/src/generate/c_api/header/mod.rs +++ b/trixy-macros/src/generate/c_api/header/mod.rs @@ -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 { diff --git a/trixy-macros/src/generate/c_api/header/pure_header.rs b/trixy-macros/src/generate/c_api/header/pure_header.rs index 7a5f49d..0137b35 100644 --- a/trixy-macros/src/generate/c_api/header/pure_header.rs +++ b/trixy-macros/src/generate/c_api/header/pure_header.rs @@ -104,9 +104,11 @@ fn enumeration_to_header(enumeration: &Enumeration) -> String { .map(doc_identifier_to_header) .collect::(); 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 {