@@ -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                } ) ; 
@@ -185,7 +187,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
185187            per_to_tokens ( 
186188                & mut  out, 
187189                & feature_attribute, 
188-                 & description , 
190+                 & doc , 
189191                & p_ty, 
190192                None , 
191193                address, 
@@ -196,7 +198,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
196198            if  derive_regs { 
197199                // re-export the base module to allow deriveFrom this one 
198200                out. extend ( quote !  { 
199-                     #[ doc = #description ] 
201+                     #[ doc = #doc ] 
200202                    #feature_attribute
201203                    pub  use  self :: #base as  #mod_ty; 
202204                } ) ; 
@@ -205,9 +207,6 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
205207        } 
206208    } 
207209
208-     let  description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & name) ) ; 
209-     let  description = util:: escape_special_chars ( & description) ; 
210- 
211210    // Build up an alternate erc list by expanding any derived registers/clusters 
212211    // erc: *E*ither *R*egister or *C*luster 
213212    let  mut  ercs = p. registers . take ( ) . unwrap_or_default ( ) ; 
@@ -246,7 +245,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
246245        register_or_cluster_block ( & ercs,  & derive_infos,  None ,  "Register block" ,  None ,  config) ?; 
247246
248247    out. extend ( quote !  { 
249-         #[ doc = #description ] 
248+         #[ doc = #doc ] 
250249        #feature_attribute
251250        pub  mod  #mod_ty
252251    } ) ; 
@@ -1381,8 +1380,9 @@ fn cluster_block(
13811380    index :  & Index , 
13821381    config :  & Config , 
13831382)  -> Result < TokenStream >  { 
1384-     let  description = util:: respace ( c. description . as_ref ( ) . unwrap_or ( & c. name ) ) ; 
1385-     let  description = util:: escape_special_chars ( & description) ; 
1383+     let  doc = c. description . as_ref ( ) . unwrap_or ( & c. name ) ; 
1384+     let  doc = util:: respace ( doc) ; 
1385+     let  doc = util:: escape_special_chars ( & doc) ; 
13861386    let  mod_name = c. name . remove_dim ( ) . to_string ( ) ; 
13871387
13881388    // name_snake_case needs to take into account array type. 
@@ -1409,7 +1409,7 @@ fn cluster_block(
14091409            . push ( path_segment ( ident ( & dname,  config,  "cluster_mod" ,  span) ) ) ; 
14101410
14111411        Ok ( quote !  { 
1412-             #[ doc = #description ] 
1412+             #[ doc = #doc ] 
14131413            pub  use  self :: #derived as  #block_ty; 
14141414            pub  use  self :: #mod_derived as  #mod_ty; 
14151415        } ) 
@@ -1429,7 +1429,7 @@ fn cluster_block(
14291429            & c. children , 
14301430            & mod_derive_infos, 
14311431            Some ( & mod_name) , 
1432-             & description , 
1432+             & doc , 
14331433            cluster_size, 
14341434            config, 
14351435        ) ?; 
@@ -1441,11 +1441,11 @@ fn cluster_block(
14411441        } ; 
14421442
14431443        Ok ( quote !  { 
1444-             #[ doc = #description ] 
1444+             #[ doc = #doc ] 
14451445            pub  use  self :: #mod_ty:: #block_ty; 
14461446
14471447            ///Cluster 
1448-              #[ doc = #description ] 
1448+              #[ doc = #doc ] 
14491449            pub  mod  #mod_ty { 
14501450                #mod_items
14511451            } 
0 commit comments