@@ -233,20 +233,26 @@ pub fn fields(
233233 } else {
234234 Ident :: from ( "bits" )
235235 } ;
236- let mut description = if width == 1 {
236+ let mut description_with_bits = if width == 1 {
237237 format ! ( "Bit {}" , offset)
238238 } else {
239239 format ! ( "Bits {}:{}" , offset, offset + width - 1 )
240240 } ;
241241 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) ) ) ;
244244 }
245+ let description = if let Some ( d) = & f. description {
246+ util:: respace ( & util:: escape_brackets ( d) )
247+ } else {
248+ "" . to_owned ( )
249+ } ;
245250
246251 Ok ( F {
247252 _pc_w,
248253 _sc,
249254 description,
255+ description_with_bits,
250256 pc_r,
251257 _pc_r,
252258 pc_w,
@@ -298,7 +304,8 @@ pub fn fields(
298304
299305 let _pc_r = & f. _pc_r ;
300306 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 ;
302309
303310 if can_read {
304311 let cast = if f. width == 1 {
@@ -322,7 +329,7 @@ pub fn fields(
322329
323330 let sc = & f. sc ;
324331 r_impl_items. push ( quote ! {
325- #[ doc = #description ]
332+ #[ doc = #description_with_bits ]
326333 #[ inline( always) ]
327334 pub fn #sc( & self ) -> #_pc_r {
328335 #_pc_r:: new( #value )
@@ -431,7 +438,7 @@ pub fn fields(
431438 } else {
432439 let sc = & f. sc ;
433440 r_impl_items. push ( quote ! {
434- #[ doc = #description ]
441+ #[ doc = #description_with_bits ]
435442 #[ inline( always) ]
436443 pub fn #sc( & self ) -> #_pc_r {
437444 #_pc_r:: new ( #value )
@@ -560,7 +567,7 @@ pub fn fields(
560567
561568 let sc = & f. sc ;
562569 w_impl_items. push ( quote ! {
563- #[ doc = #description ]
570+ #[ doc = #description_with_bits ]
564571 #[ inline( always) ]
565572 pub fn #sc( & mut self ) -> #_pc_w {
566573 #_pc_w { w: self }
@@ -720,6 +727,7 @@ struct F<'a> {
720727 _sc : Ident ,
721728 access : Option < Access > ,
722729 description : String ,
730+ description_with_bits : String ,
723731 evs : & ' a [ EnumeratedValues ] ,
724732 mask : u64 ,
725733 name : & ' a str ,
0 commit comments