@@ -406,8 +406,32 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
406406 let node_input_accessor = generate_node_input_references ( parsed, fn_generics, & field_idents, core_types, & identifier, & cfg) ;
407407 let ShaderTokens { shader_entry_point, gpu_node } = attributes. shader_node . as_ref ( ) . map ( |n| n. codegen ( crate_ident, parsed) ) . unwrap_or ( Ok ( ShaderTokens :: default ( ) ) ) ?;
408408
409+ let display_name_header = format ! ( "# {display_name}" ) ;
410+ let mut description_doc_attrs = vec ! [ quote!( #[ doc = #display_name_header] ) , quote!( #[ doc = "" ] ) ] ;
411+ description_doc_attrs. extend ( description. lines ( ) . map ( |line| quote ! ( #[ doc = #line] ) ) ) ;
412+
413+ // Add parameter list to doc comment
414+ if !input_names. is_empty ( ) {
415+ description_doc_attrs. push ( quote ! ( #[ doc = "" ] ) ) ;
416+ description_doc_attrs. push ( quote ! ( #[ doc = "## Parameters" ] ) ) ;
417+ for ( name, desc) in input_names. iter ( ) . zip ( input_descriptions. iter ( ) ) {
418+ if desc. is_empty ( ) {
419+ let header = format ! ( "- **{name}**" ) ;
420+ description_doc_attrs. push ( quote ! ( #[ doc = #header] ) ) ;
421+ } else {
422+ let first_line = desc. lines ( ) . next ( ) . unwrap_or ( "" ) ;
423+ let header = format ! ( "- **{name}**: {first_line}" ) ;
424+ description_doc_attrs. push ( quote ! ( #[ doc = #header] ) ) ;
425+ for line in desc. lines ( ) . skip ( 1 ) {
426+ let continuation = format ! ( " {line}" ) ;
427+ description_doc_attrs. push ( quote ! ( #[ doc = #continuation] ) ) ;
428+ }
429+ }
430+ }
431+ }
432+
409433 Ok ( quote ! {
410- /// Underlying implementation for [#struct_name]
434+ # ( #description_doc_attrs ) *
411435 #[ inline]
412436 #[ allow( clippy:: too_many_arguments) ]
413437 #vis #async_keyword fn #fn_name <' n, #( #fn_generics, ) * > ( #input_ident: #input_type #( , #data_field_idents: #data_field_types) * #( , #field_idents: #field_types) * ) -> #output_type #where_clause #body
0 commit comments