@@ -343,7 +343,7 @@ fn expand_derive(input: DeriveInput) -> syn::Result<TokenStream2> {
343343 let mut has_clock_port = false ;
344344 // #[interface] fields, spliced into the manifest by const
345345 // concatenation.
346- let mut groups: Vec < ( String , Type ) > = Vec :: new ( ) ;
346+ let mut groups: Vec < ( String , Type , Option < String > ) > = Vec :: new ( ) ;
347347 // Port and group names share the connection-item namespace, so
348348 // duplicates are rejected here where both declarations are visible.
349349 let mut port_names: std:: collections:: HashSet < String > = std:: collections:: HashSet :: new ( ) ;
@@ -378,7 +378,7 @@ fn expand_derive(input: DeriveInput) -> syn::Result<TokenStream2> {
378378 let ty = field. ty . clone ( ) ;
379379 inits. push ( quote ! ( #field_ident:
380380 <#ty as :: veryl_component:: VerylInterface >:: resolve( ctx, #group) ?) ) ;
381- groups. push ( ( group, ty) ) ;
381+ groups. push ( ( group, ty, doc ) ) ;
382382 continue ;
383383 }
384384
@@ -502,11 +502,14 @@ fn expand_derive(input: DeriveInput) -> syn::Result<TokenStream2> {
502502 // Splicing another type's consts needs const concatenation; a component
503503 // without interface fields keeps the plain literal.
504504 let mut decl_parts: Vec < TokenStream2 > = vec ! [ quote!( #decl_prefix) ] ;
505- for ( i, ( group, ty) ) in groups. iter ( ) . enumerate ( ) {
505+ for ( i, ( group, ty, doc ) ) in groups. iter ( ) . enumerate ( ) {
506506 let head = format ! (
507- r#"{}{{"name":"{}", "interface":""# ,
507+ r#"{}{{"name":"{}"{} "interface":""# ,
508508 if i == 0 { "" } else { "," } ,
509509 json_escape( group) ,
510+ doc. as_ref( )
511+ . map( |d| format!( r#","doc":"{}","# , json_escape( d) ) )
512+ . unwrap_or_else( || "," . to_string( ) ) ,
510513 ) ;
511514 decl_parts. push ( quote ! ( #head) ) ;
512515 decl_parts. push ( quote ! ( <#ty as :: veryl_component:: VerylInterface >:: INTERFACE_PATH ) ) ;
0 commit comments