@@ -108,6 +108,7 @@ pub fn render(
108
108
return Err ( anyhow ! ( "Incorrect access of register {}" , register. name) ) ;
109
109
} ;
110
110
111
+ let rpath = path. new_register ( & register. name ) ;
111
112
let mut alias_doc = format ! (
112
113
"{name} ({accs}) register accessor: {description}{}{}" ,
113
114
api_docs(
@@ -116,6 +117,9 @@ pub fn render(
116
117
register. properties. reset_value. is_some( ) ,
117
118
& mod_ty,
118
119
false ,
120
+ & register,
121
+ & rpath,
122
+ config,
119
123
) ?,
120
124
read_action_docs( access. can_read( ) , register. read_action) ,
121
125
) ;
@@ -128,13 +132,7 @@ pub fn render(
128
132
#doc_alias
129
133
pub type #reg_ty = crate :: Reg <#mod_ty:: #regspec_ty>;
130
134
} ) ;
131
- let mod_items = render_register_mod (
132
- register,
133
- access,
134
- & path. new_register ( & register. name ) ,
135
- index,
136
- config,
137
- ) ?;
135
+ let mod_items = render_register_mod ( register, access, & rpath, index, config) ?;
138
136
139
137
out. extend ( quote ! {
140
138
#[ doc = #description]
@@ -170,6 +168,9 @@ fn api_docs(
170
168
can_reset : bool ,
171
169
module : & Ident ,
172
170
inmodule : bool ,
171
+ register : & Register ,
172
+ rpath : & RegisterPath ,
173
+ config : & Config ,
173
174
) -> Result < String , std:: fmt:: Error > {
174
175
fn method ( s : & str ) -> String {
175
176
format ! ( "[`{s}`](crate::Reg::{s})" )
@@ -211,13 +212,35 @@ fn api_docs(
211
212
212
213
doc. push_str ( "See [API](https://docs.rs/svd2rust/#read--modify--write-api)." ) ;
213
214
215
+ if let Some ( url) = config. html_url . as_ref ( ) {
216
+ let first_idx = if let Register :: Array ( _, dim) = & register {
217
+ dim. indexes ( ) . next ( )
218
+ } else {
219
+ None
220
+ } ;
221
+ let rname = if let Some ( idx) = first_idx {
222
+ let idx = format ! ( "[{idx}]" ) ;
223
+ rpath. name . replace ( "[%s]" , & idx) . replace ( "%s" , & idx)
224
+ } else {
225
+ rpath. name . to_string ( )
226
+ } ;
227
+ // TODO: support html_urls for registers in cluster
228
+ if rpath. block . path . is_empty ( ) {
229
+ doc. push_str ( & format ! (
230
+ "\n \n See register [structure]({url}#{}:{})" ,
231
+ rpath. peripheral( ) ,
232
+ rname
233
+ ) ) ;
234
+ }
235
+ }
236
+
214
237
Ok ( doc)
215
238
}
216
239
217
240
pub fn render_register_mod (
218
241
register : & Register ,
219
242
access : Access ,
220
- path : & RegisterPath ,
243
+ rpath : & RegisterPath ,
221
244
index : & Index ,
222
245
config : & Config ,
223
246
) -> Result < TokenStream > {
@@ -312,7 +335,7 @@ pub fn render_register_mod(
312
335
access,
313
336
properties,
314
337
& mut mod_items,
315
- path ,
338
+ rpath ,
316
339
index,
317
340
config,
318
341
) ?;
@@ -361,7 +384,7 @@ pub fn render_register_mod(
361
384
362
385
let doc = format ! (
363
386
"{description}{}{}" ,
364
- api_docs( can_read, can_write, can_reset, & mod_ty, true ) ?,
387
+ api_docs( can_read, can_write, can_reset, & mod_ty, true , register , rpath , config ) ?,
365
388
read_action_docs( access. can_read( ) , register. read_action) ,
366
389
) ;
367
390
0 commit comments