@@ -42,7 +42,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
42
42
let p_ty = ident ( & name, config, "peripheral" , span) ;
43
43
let name_str = p_ty. to_string ( ) ;
44
44
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) ;
46
47
47
48
let mod_ty = ident ( & name, config, "peripheral_mod" , span) ;
48
49
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
88
89
89
90
let per_to_tokens = |out : & mut TokenStream ,
90
91
feature_attribute : & TokenStream ,
91
- description : & str ,
92
+ doc : & str ,
92
93
p_ty : & Ident ,
93
94
doc_alias : Option < TokenStream > ,
94
95
address : LitInt | {
95
96
out. extend ( quote ! {
96
- #[ doc = #description ]
97
+ #[ doc = #doc ]
97
98
#phtml
98
99
#doc_alias
99
100
#feature_attribute
@@ -140,7 +141,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
140
141
let mut feature_names = Vec :: with_capacity ( dim. dim as _ ) ;
141
142
for pi in svd:: peripheral:: expand ( p, dim) {
142
143
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) ;
144
146
let p_ty = ident ( name, config, "peripheral" , span) ;
145
147
let name_str = p_ty. to_string ( ) ;
146
148
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
155
157
per_to_tokens (
156
158
& mut out,
157
159
& feature_attribute_n,
158
- description ,
160
+ & doc ,
159
161
& p_ty,
160
162
doc_alias,
161
163
address,
@@ -169,7 +171,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
169
171
if derive_regs {
170
172
// re-export the base module to allow deriveFrom this one
171
173
out. extend ( quote ! {
172
- #[ doc = #description ]
174
+ #[ doc = #doc ]
173
175
#feature_any_attribute
174
176
pub use self :: #base as #mod_ty;
175
177
} ) ;
@@ -182,21 +184,14 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
182
184
feature_attribute. extend ( quote ! { #[ cfg( feature = #p_feature) ] } )
183
185
} ;
184
186
// 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) ;
193
188
194
189
// Derived peripherals may not require re-implementation, and will instead
195
190
// use a single definition of the non-derived version.
196
191
if derive_regs {
197
192
// re-export the base module to allow deriveFrom this one
198
193
out. extend ( quote ! {
199
- #[ doc = #description ]
194
+ #[ doc = #doc ]
200
195
#feature_attribute
201
196
pub use self :: #base as #mod_ty;
202
197
} ) ;
@@ -205,9 +200,6 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
205
200
}
206
201
}
207
202
208
- let description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & name) ) ;
209
- let description = util:: escape_special_chars ( & description) ;
210
-
211
203
// Build up an alternate erc list by expanding any derived registers/clusters
212
204
// erc: *E*ither *R*egister or *C*luster
213
205
let mut ercs = p. registers . take ( ) . unwrap_or_default ( ) ;
@@ -246,7 +238,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
246
238
register_or_cluster_block ( & ercs, & derive_infos, None , "Register block" , None , config) ?;
247
239
248
240
out. extend ( quote ! {
249
- #[ doc = #description ]
241
+ #[ doc = #doc ]
250
242
#feature_attribute
251
243
pub mod #mod_ty
252
244
} ) ;
@@ -1381,8 +1373,9 @@ fn cluster_block(
1381
1373
index : & Index ,
1382
1374
config : & Config ,
1383
1375
) -> 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) ;
1386
1379
let mod_name = c. name . remove_dim ( ) . to_string ( ) ;
1387
1380
1388
1381
// name_snake_case needs to take into account array type.
@@ -1409,7 +1402,7 @@ fn cluster_block(
1409
1402
. push ( path_segment ( ident ( & dname, config, "cluster_mod" , span) ) ) ;
1410
1403
1411
1404
Ok ( quote ! {
1412
- #[ doc = #description ]
1405
+ #[ doc = #doc ]
1413
1406
pub use #derived as #block_ty;
1414
1407
pub use #mod_derived as #mod_ty;
1415
1408
} )
@@ -1429,7 +1422,7 @@ fn cluster_block(
1429
1422
& c. children ,
1430
1423
& mod_derive_infos,
1431
1424
Some ( & mod_name) ,
1432
- & description ,
1425
+ & doc ,
1433
1426
cluster_size,
1434
1427
config,
1435
1428
) ?;
@@ -1441,11 +1434,11 @@ fn cluster_block(
1441
1434
} ;
1442
1435
1443
1436
Ok ( quote ! {
1444
- #[ doc = #description ]
1437
+ #[ doc = #doc ]
1445
1438
pub use self :: #mod_ty:: #block_ty;
1446
1439
1447
1440
///Cluster
1448
- #[ doc = #description ]
1441
+ #[ doc = #doc ]
1449
1442
pub mod #mod_ty {
1450
1443
#mod_items
1451
1444
}
0 commit comments