@@ -83,16 +83,18 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
83
83
let description = pi. description . as_deref ( ) . unwrap_or ( & p. name ) ;
84
84
let p_ty = ident ( name, & config. ident_formats . peripheral , span) ;
85
85
let name_str = p_ty. to_string ( ) ;
86
+ let doc_alias = ( & name_str != name) . then ( || quote ! ( #[ doc( alias = #name) ] ) ) ;
86
87
let address = util:: hex ( pi. base_address + config. base_address_shift ) ;
87
- let feature_name = config. ident_formats . peripheral_feature . apply ( name) ;
88
- feature_names. push ( feature_name . to_string ( ) ) ;
88
+ let p_feature = config. ident_formats . peripheral_feature . apply ( name) ;
89
+ feature_names. push ( p_feature . to_string ( ) ) ;
89
90
let mut feature_attribute_n = feature_attribute. clone ( ) ;
90
91
if config. feature_peripheral {
91
- feature_attribute_n. extend ( quote ! { #[ cfg( feature = #feature_name ) ] } )
92
+ feature_attribute_n. extend ( quote ! { #[ cfg( feature = #p_feature ) ] } )
92
93
} ;
93
94
// Insert the peripherals structure
94
95
out. extend ( quote ! {
95
96
#[ doc = #description]
97
+ #doc_alias
96
98
#feature_attribute_n
97
99
pub struct #p_ty { _marker: PhantomData <* const ( ) > }
98
100
@@ -147,9 +149,9 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
147
149
}
148
150
}
149
151
Peripheral :: Single ( _) => {
150
- let feature_name = config. ident_formats . peripheral_feature . apply ( & name) ;
152
+ let p_feature = config. ident_formats . peripheral_feature . apply ( & name) ;
151
153
if config. feature_peripheral {
152
- feature_attribute. extend ( quote ! { #[ cfg( feature = #feature_name ) ] } )
154
+ feature_attribute. extend ( quote ! { #[ cfg( feature = #p_feature ) ] } )
153
155
} ;
154
156
// Insert the peripheral structure
155
157
out. extend ( quote ! {
@@ -244,7 +246,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
244
246
"Pushing {} register or cluster blocks into output" ,
245
247
ercs. len( )
246
248
) ;
247
- let reg_block = register_or_cluster_block ( & ercs, & derive_infos, None , None , config) ?;
249
+ let reg_block =
250
+ register_or_cluster_block ( & ercs, & derive_infos, None , "Register block" , None , config) ?;
248
251
249
252
let open = Punct :: new ( '{' , Spacing :: Alone ) ;
250
253
let close = Punct :: new ( '}' , Spacing :: Alone ) ;
@@ -526,6 +529,7 @@ fn register_or_cluster_block(
526
529
ercs : & [ RegisterCluster ] ,
527
530
derive_infos : & [ DeriveInfo ] ,
528
531
name : Option < & str > ,
532
+ doc : & str ,
529
533
size : Option < u32 > ,
530
534
config : & Config ,
531
535
) -> Result < TokenStream > {
@@ -630,8 +634,13 @@ fn register_or_cluster_block(
630
634
}
631
635
} ) ;
632
636
637
+ let mut doc_alias = None ;
633
638
let block_ty = if let Some ( name) = name {
634
- ident ( name, & config. ident_formats . cluster , span)
639
+ let ty = ident ( name, & config. ident_formats . cluster , span) ;
640
+ if ty. to_string ( ) != name {
641
+ doc_alias = Some ( quote ! ( #[ doc( alias = #name) ] ) ) ;
642
+ }
643
+ ty
635
644
} else {
636
645
Ident :: new ( "RegisterBlock" , span)
637
646
} ;
@@ -645,9 +654,10 @@ fn register_or_cluster_block(
645
654
} ) ;
646
655
647
656
Ok ( quote ! {
648
- ///Register block
649
657
#[ repr( C ) ]
650
658
#derive_debug
659
+ #[ doc = #doc]
660
+ #doc_alias
651
661
pub struct #block_ty {
652
662
#rbfs
653
663
}
@@ -1429,6 +1439,7 @@ fn cluster_block(
1429
1439
& c. children ,
1430
1440
& mod_derive_infos,
1431
1441
Some ( & mod_name) ,
1442
+ & description,
1432
1443
cluster_size,
1433
1444
config,
1434
1445
) ?;
0 commit comments