@@ -42,8 +42,9 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
4242 let p_ty = ident ( & name, config, "peripheral" , span) ;
4343 let name_str = p_ty. to_string ( ) ;
4444 let address = util:: hex ( p. base_address + config. base_address_shift ) ;
45- let doc = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & name) ) ;
46- let doc = util:: escape_special_chars ( & doc) ;
45+ let doc = util:: escape_special_chars ( p. description . as_ref ( ) . unwrap_or ( & name) ) ;
46+ let doc = util:: respace ( & doc) ;
47+ let doc = quote ! { #[ doc = #doc] } ;
4748
4849 let mod_ty = ident ( & name, config, "peripheral_mod" , span) ;
4950 let ( derive_regs, base, path) = if let Some ( path) = path {
@@ -65,19 +66,19 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
6566
6667 let phtml = config. settings . html_url . as_ref ( ) . map ( |url| {
6768 let doc = format ! ( "See peripheral [structure]({url}#{})" , & path. peripheral) ;
68- quote ! ( #[ doc = "" ] #[ doc = #doc ] )
69+ quote ! ( #[ doc = "" ] #doc)
6970 } ) ;
7071
7172 let per_to_tokens = |out : & mut TokenStream ,
7273 feature_attribute : & TokenStream ,
73- doc : & str ,
74+ doc : & TokenStream ,
7475 p_ty : & Ident ,
7576 name_str : & str ,
7677 doc_alias : Option < TokenStream > ,
7778 address : LitInt | {
7879 let pspec = ident ( name_str, config, "peripheral_spec" , Span :: call_site ( ) ) ;
7980 out. extend ( quote ! {
80- #[ doc = #doc ]
81+ #doc
8182 #phtml
8283 #doc_alias
8384 #feature_attribute
@@ -100,8 +101,9 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
100101 let mut feature_names = Vec :: with_capacity ( dim. dim as _ ) ;
101102 for pi in svd:: peripheral:: expand ( p, dim) {
102103 let name = & pi. name ;
103- let doc = util:: respace ( pi. description . as_ref ( ) . unwrap_or ( & pi. name ) ) ;
104- let doc = util:: escape_special_chars ( & doc) ;
104+ let doc = util:: escape_special_chars ( pi. description . as_ref ( ) . unwrap_or ( & pi. name ) ) ;
105+ let doc = util:: respace ( & doc) ;
106+ let doc = quote ! { #[ doc = #doc] } ;
105107 let p_ty = ident ( name, config, "peripheral" , span) ;
106108 let name_str = p_ty. to_string ( ) ;
107109 let doc_alias = ( & name_str != name) . then ( || quote ! ( #[ doc( alias = #name) ] ) ) ;
@@ -131,7 +133,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
131133 if derive_regs {
132134 // re-export the base module to allow deriveFrom this one
133135 out. extend ( quote ! {
134- #[ doc = #doc ]
136+ #doc
135137 #feature_any_attribute
136138 pub use self :: #base as #mod_ty;
137139 } ) ;
@@ -159,7 +161,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
159161 if derive_regs {
160162 // re-export the base module to allow deriveFrom this one
161163 out. extend ( quote ! {
162- #[ doc = #doc ]
164+ #doc
163165 #feature_attribute
164166 pub use self :: #base as #mod_ty;
165167 } ) ;
@@ -207,13 +209,13 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
207209 & BlockPath :: new ( & p. name ) ,
208210 & derive_infos,
209211 None ,
210- "Register block" ,
212+ & quote ! { # [ doc = "Register block" ] } ,
211213 None ,
212214 config,
213215 ) ?;
214216
215217 out. extend ( quote ! {
216- #[ doc = #doc ]
218+ #doc
217219 #feature_attribute
218220 pub mod #mod_ty
219221 } ) ;
@@ -478,8 +480,8 @@ impl FieldRegions {
478480}
479481
480482fn make_comment ( size : u32 , offset : u32 , description : & str ) -> String {
481- let desc = util:: respace ( description) ;
482- let desc = util:: escape_special_chars ( & desc) ;
483+ let desc = util:: escape_special_chars ( description) ;
484+ let desc = util:: respace ( & desc) ;
483485 if size > 32 {
484486 let end = offset + size / 8 ;
485487 format ! ( "0x{offset:02x}..0x{end:02x} - {desc}" )
@@ -493,7 +495,7 @@ fn register_or_cluster_block(
493495 path : & BlockPath ,
494496 derive_infos : & [ DeriveInfo ] ,
495497 name : Option < & str > ,
496- doc : & str ,
498+ doc : & TokenStream ,
497499 size : Option < u32 > ,
498500 config : & Config ,
499501) -> Result < TokenStream > {
@@ -620,7 +622,7 @@ fn register_or_cluster_block(
620622 Ok ( quote ! {
621623 #[ repr( C ) ]
622624 #derive_debug
623- #[ doc = #doc ]
625+ #doc
624626 #doc_alias
625627 pub struct #block_ty {
626628 #rbfs
@@ -1355,8 +1357,9 @@ fn cluster_block(
13551357 config : & Config ,
13561358) -> Result < TokenStream > {
13571359 let doc = c. description . as_ref ( ) . unwrap_or ( & c. name ) ;
1358- let doc = util:: respace ( doc) ;
1359- let doc = util:: escape_special_chars ( & doc) ;
1360+ let doc = util:: escape_special_chars ( doc) ;
1361+ let doc = util:: respace ( & doc) ;
1362+ let doc = quote ! { #[ doc = #doc] } ;
13601363 let mod_name = c. name . remove_dim ( ) . to_string ( ) ;
13611364
13621365 // name_snake_case needs to take into account array type.
@@ -1383,7 +1386,7 @@ fn cluster_block(
13831386 . push ( path_segment ( ident ( & dname, config, "cluster_mod" , span) ) ) ;
13841387
13851388 Ok ( quote ! {
1386- #[ doc = #doc ]
1389+ #doc
13871390 pub use #derived as #block_ty;
13881391 pub use #mod_derived as #mod_ty;
13891392 } )
@@ -1416,11 +1419,11 @@ fn cluster_block(
14161419 } ;
14171420
14181421 Ok ( quote ! {
1419- #[ doc = #doc ]
1422+ #doc
14201423 pub use self :: #mod_ty:: #block_ty;
14211424
14221425 ///Cluster
1423- #[ doc = #doc ]
1426+ #doc
14241427 pub mod #mod_ty {
14251428 #mod_items
14261429 }
0 commit comments