@@ -233,20 +233,26 @@ pub fn fields(
233
233
} else {
234
234
Ident :: from ( "bits" )
235
235
} ;
236
- let mut description = if width == 1 {
236
+ let mut description_with_bits = if width == 1 {
237
237
format ! ( "Bit {}" , offset)
238
238
} else {
239
239
format ! ( "Bits {}:{}" , offset, offset + width - 1 )
240
240
} ;
241
241
if let Some ( d) = & f. description {
242
- description . push_str ( " - " ) ;
243
- description . push_str ( & * util:: respace ( & util:: escape_brackets ( d) ) ) ;
242
+ description_with_bits . push_str ( " - " ) ;
243
+ description_with_bits . push_str ( & * util:: respace ( & util:: escape_brackets ( d) ) ) ;
244
244
}
245
+ let description = if let Some ( d) = & f. description {
246
+ util:: respace ( & util:: escape_brackets ( d) )
247
+ } else {
248
+ "" . to_owned ( )
249
+ } ;
245
250
246
251
Ok ( F {
247
252
_pc_w,
248
253
_sc,
249
254
description,
255
+ description_with_bits,
250
256
pc_r,
251
257
_pc_r,
252
258
pc_w,
@@ -298,7 +304,8 @@ pub fn fields(
298
304
299
305
let _pc_r = & f. _pc_r ;
300
306
let _pc_w = & f. _pc_w ;
301
- let description = & util:: escape_brackets ( & f. description ) ;
307
+ let description = & f. description ;
308
+ let description_with_bits = & f. description_with_bits ;
302
309
303
310
if can_read {
304
311
let cast = if f. width == 1 {
@@ -322,7 +329,7 @@ pub fn fields(
322
329
323
330
let sc = & f. sc ;
324
331
r_impl_items. push ( quote ! {
325
- #[ doc = #description ]
332
+ #[ doc = #description_with_bits ]
326
333
#[ inline( always) ]
327
334
pub fn #sc( & self ) -> #_pc_r {
328
335
#_pc_r:: new( #value )
@@ -431,7 +438,7 @@ pub fn fields(
431
438
} else {
432
439
let sc = & f. sc ;
433
440
r_impl_items. push ( quote ! {
434
- #[ doc = #description ]
441
+ #[ doc = #description_with_bits ]
435
442
#[ inline( always) ]
436
443
pub fn #sc( & self ) -> #_pc_r {
437
444
#_pc_r:: new ( #value )
@@ -560,7 +567,7 @@ pub fn fields(
560
567
561
568
let sc = & f. sc ;
562
569
w_impl_items. push ( quote ! {
563
- #[ doc = #description ]
570
+ #[ doc = #description_with_bits ]
564
571
#[ inline( always) ]
565
572
pub fn #sc( & mut self ) -> #_pc_w {
566
573
#_pc_w { w: self }
@@ -720,6 +727,7 @@ struct F<'a> {
720
727
_sc : Ident ,
721
728
access : Option < Access > ,
722
729
description : String ,
730
+ description_with_bits : String ,
723
731
evs : & ' a [ EnumeratedValues ] ,
724
732
mask : u64 ,
725
733
name : & ' a str ,
0 commit comments