@@ -42,7 +42,8 @@ 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 description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & p. name ) ) ;
45+ let doc = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & name) ) ;
46+ let doc = util:: escape_special_chars ( & doc) ;
4647
4748 let mod_ty = ident ( & name, config, "peripheral_mod" , span) ;
4849 let ( derive_regs, base, path) = if let Some ( path) = path {
@@ -88,12 +89,12 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
8889
8990 let per_to_tokens = |out : & mut TokenStream ,
9091 feature_attribute : & TokenStream ,
91- description : & str ,
92+ doc : & str ,
9293 p_ty : & Ident ,
9394 doc_alias : Option < TokenStream > ,
9495 address : LitInt | {
9596 out. extend ( quote ! {
96- #[ doc = #description ]
97+ #[ doc = #doc ]
9798 #phtml
9899 #doc_alias
99100 #feature_attribute
@@ -140,7 +141,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
140141 let mut feature_names = Vec :: with_capacity ( dim. dim as _ ) ;
141142 for pi in svd:: peripheral:: expand ( p, dim) {
142143 let name = & pi. name ;
143- let description = pi. description . as_deref ( ) . unwrap_or ( & p. name ) ;
144+ let doc = util:: respace ( pi. description . as_ref ( ) . unwrap_or ( & pi. name ) ) ;
145+ let doc = util:: escape_special_chars ( & doc) ;
144146 let p_ty = ident ( name, config, "peripheral" , span) ;
145147 let name_str = p_ty. to_string ( ) ;
146148 let doc_alias = ( & name_str != name) . then ( || quote ! ( #[ doc( alias = #name) ] ) ) ;
@@ -155,7 +157,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
155157 per_to_tokens (
156158 & mut out,
157159 & feature_attribute_n,
158- description ,
160+ & doc ,
159161 & p_ty,
160162 doc_alias,
161163 address,
@@ -169,7 +171,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
169171 if derive_regs {
170172 // re-export the base module to allow deriveFrom this one
171173 out. extend ( quote ! {
172- #[ doc = #description ]
174+ #[ doc = #doc ]
173175 #feature_any_attribute
174176 pub use self :: #base as #mod_ty;
175177 } ) ;
@@ -182,21 +184,14 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
182184 feature_attribute. extend ( quote ! { #[ cfg( feature = #p_feature) ] } )
183185 } ;
184186 // Insert the peripheral structure
185- per_to_tokens (
186- & mut out,
187- & feature_attribute,
188- & description,
189- & p_ty,
190- None ,
191- address,
192- ) ;
187+ per_to_tokens ( & mut out, & feature_attribute, & doc, & p_ty, None , address) ;
193188
194189 // Derived peripherals may not require re-implementation, and will instead
195190 // use a single definition of the non-derived version.
196191 if derive_regs {
197192 // re-export the base module to allow deriveFrom this one
198193 out. extend ( quote ! {
199- #[ doc = #description ]
194+ #[ doc = #doc ]
200195 #feature_attribute
201196 pub use self :: #base as #mod_ty;
202197 } ) ;
@@ -205,9 +200,6 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
205200 }
206201 }
207202
208- let description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & name) ) ;
209- let description = util:: escape_special_chars ( & description) ;
210-
211203 // Build up an alternate erc list by expanding any derived registers/clusters
212204 // erc: *E*ither *R*egister or *C*luster
213205 let mut ercs = p. registers . take ( ) . unwrap_or_default ( ) ;
@@ -246,7 +238,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
246238 register_or_cluster_block ( & ercs, & derive_infos, None , "Register block" , None , config) ?;
247239
248240 out. extend ( quote ! {
249- #[ doc = #description ]
241+ #[ doc = #doc ]
250242 #feature_attribute
251243 pub mod #mod_ty
252244 } ) ;
@@ -1381,8 +1373,9 @@ fn cluster_block(
13811373 index : & Index ,
13821374 config : & Config ,
13831375) -> Result < TokenStream > {
1384- let description = util:: respace ( c. description . as_ref ( ) . unwrap_or ( & c. name ) ) ;
1385- let description = util:: escape_special_chars ( & description) ;
1376+ let doc = c. description . as_ref ( ) . unwrap_or ( & c. name ) ;
1377+ let doc = util:: respace ( doc) ;
1378+ let doc = util:: escape_special_chars ( & doc) ;
13861379 let mod_name = c. name . remove_dim ( ) . to_string ( ) ;
13871380
13881381 // name_snake_case needs to take into account array type.
@@ -1409,7 +1402,7 @@ fn cluster_block(
14091402 . push ( path_segment ( ident ( & dname, config, "cluster_mod" , span) ) ) ;
14101403
14111404 Ok ( quote ! {
1412- #[ doc = #description ]
1405+ #[ doc = #doc ]
14131406 pub use #derived as #block_ty;
14141407 pub use #mod_derived as #mod_ty;
14151408 } )
@@ -1429,7 +1422,7 @@ fn cluster_block(
14291422 & c. children ,
14301423 & mod_derive_infos,
14311424 Some ( & mod_name) ,
1432- & description ,
1425+ & doc ,
14331426 cluster_size,
14341427 config,
14351428 ) ?;
@@ -1441,11 +1434,11 @@ fn cluster_block(
14411434 } ;
14421435
14431436 Ok ( quote ! {
1444- #[ doc = #description ]
1437+ #[ doc = #doc ]
14451438 pub use self :: #mod_ty:: #block_ty;
14461439
14471440 ///Cluster
1448- #[ doc = #description ]
1441+ #[ doc = #doc ]
14491442 pub mod #mod_ty {
14501443 #mod_items
14511444 }
0 commit comments