@@ -103,7 +103,7 @@ fn main() -> Result<()> {
103
103
let mappings_path = matches. get_one :: < String > ( "mappings" ) . unwrap ( ) ;
104
104
105
105
let input_content = fs:: read_to_string ( input_path)
106
- . with_context ( || format ! ( "Failed to read input JSON file: {}" , input_path ) ) ?;
106
+ . with_context ( || format ! ( "Failed to read input JSON file: {input_path}" ) ) ?;
107
107
108
108
let config_docs: ConfigDocs =
109
109
serde_json:: from_str ( & input_content) . with_context ( || "Failed to parse input JSON" ) ?;
@@ -113,27 +113,24 @@ fn main() -> Result<()> {
113
113
let markdown = generate_markdown ( & config_docs, template_path, & custom_mappings) ?;
114
114
115
115
fs:: write ( output_path, markdown)
116
- . with_context ( || format ! ( "Failed to write output file: {}" , output_path ) ) ?;
116
+ . with_context ( || format ! ( "Failed to write output file: {output_path}" ) ) ?;
117
117
118
118
println ! (
119
- "Successfully generated Markdown documentation at {}" ,
120
- output_path
119
+ "Successfully generated Markdown documentation at {output_path}"
121
120
) ;
122
121
Ok ( ( ) )
123
122
}
124
123
125
124
fn load_section_name_mappings ( mappings_file : & str ) -> Result < HashMap < String , String > > {
126
125
let content = fs:: read_to_string ( mappings_file) . with_context ( || {
127
126
format ! (
128
- "Failed to read section name mappings file: {}" ,
129
- mappings_file
127
+ "Failed to read section name mappings file: {mappings_file}"
130
128
)
131
129
} ) ?;
132
130
133
131
let mappings: HashMap < String , String > = serde_json:: from_str ( & content) . with_context ( || {
134
132
format ! (
135
- "Failed to parse section name mappings JSON: {}" ,
136
- mappings_file
133
+ "Failed to parse section name mappings JSON: {mappings_file}"
137
134
)
138
135
} ) ?;
139
136
@@ -142,14 +139,14 @@ fn load_section_name_mappings(mappings_file: &str) -> Result<HashMap<String, Str
142
139
143
140
fn load_template ( template_path : & str ) -> Result < String > {
144
141
fs:: read_to_string ( template_path)
145
- . with_context ( || format ! ( "Failed to read template file: {}" , template_path ) )
142
+ . with_context ( || format ! ( "Failed to read template file: {template_path}" ) )
146
143
}
147
144
148
145
fn render_template ( template : & str , variables : HashMap < String , String > ) -> String {
149
146
let mut result = template. to_string ( ) ;
150
147
151
148
for ( key, value) in variables {
152
- let placeholder = format ! ( "{{{{{}}}}}" , key ) ;
149
+ let placeholder = format ! ( "{{{{{key }}}}}" ) ;
153
150
result = result. replace ( & placeholder, & value) ;
154
151
}
155
152
@@ -245,7 +242,7 @@ fn generate_struct_section(
245
242
custom_mappings : & HashMap < String , String > ,
246
243
) -> Result < ( ) > {
247
244
let section_name = struct_to_section_name ( & struct_doc. name , custom_mappings) ;
248
- output. push_str ( & format ! ( "## {}\n \n " , section_name ) ) ;
245
+ output. push_str ( & format ! ( "## {section_name }\n \n " ) ) ;
249
246
250
247
// Add struct description if available
251
248
if let Some ( description) = & struct_doc. description {
@@ -365,7 +362,7 @@ fn generate_field_row(
365
362
366
363
// Add deprecation warning if present
367
364
if let Some ( deprecated) = & field. deprecated {
368
- description_parts. push ( format ! ( "<br><br>**⚠️ DEPRECATED:** {}" , deprecated ) ) ;
365
+ description_parts. push ( format ! ( "<br><br>**⚠️ DEPRECATED:** {deprecated}" ) ) ;
369
366
}
370
367
371
368
// Add TOML example if present
@@ -385,16 +382,15 @@ fn generate_field_row(
385
382
. replace ( '\n' , " " ) ; // Use HTML entity for newline to avoid <br> conversion
386
383
387
384
let example_section = format ! (
388
- "<br><br>**Example:**<br><pre><code>{}</code></pre>" ,
389
- escaped_example // HTML entities will be rendered as newlines by <pre>
385
+ "<br><br>**Example:**<br><pre><code>{escaped_example}</code></pre>" // HTML entities will be rendered as newlines by <pre>
390
386
) ;
391
387
description_parts. push ( example_section) ;
392
388
}
393
389
394
390
// Add units information if present
395
391
if let Some ( units) = & field. units {
396
392
let units_text = process_intralinks_with_context ( units, global_context, struct_name) ;
397
- description_parts. push ( format ! ( "<br><br>**Units:** {}" , units_text ) ) ;
393
+ description_parts. push ( format ! ( "<br><br>**Units:** {units_text}" ) ) ;
398
394
}
399
395
400
396
let description = if description_parts. is_empty ( ) {
@@ -513,11 +509,11 @@ fn process_reference(
513
509
// Check if it's the same struct or different struct
514
510
if ref_struct_name == current_struct_name {
515
511
// Same struct: just show field name
516
- return format ! ( "[{}](#{}) " , field_name , anchor_id ) ;
512
+ return format ! ( "[{field_name }](#{anchor_id }) " ) ;
517
513
} else {
518
514
// Different struct: show [config_section].field_name as a link
519
515
let config_section = section_name. trim_start_matches ( '[' ) . trim_end_matches ( ']' ) ;
520
- return format ! ( "[[{}].{}](#{}) " , config_section , field_name , anchor_id ) ;
516
+ return format ! ( "[[{config_section }].{field_name }](#{anchor_id }) " ) ;
521
517
}
522
518
}
523
519
}
@@ -540,11 +536,11 @@ fn process_reference(
540
536
// Check if it's the same struct or different struct
541
537
if field_struct_name == current_struct_name {
542
538
// Same struct: just show field name
543
- return format ! ( "[{}](#{}) " , reference , anchor_id ) ;
539
+ return format ! ( "[{reference }](#{anchor_id }) " ) ;
544
540
} else {
545
541
// Different struct: show [config_section].field_name as a link
546
542
let config_section = section_name. trim_start_matches ( '[' ) . trim_end_matches ( ']' ) ;
547
- return format ! ( "[[{}].{}](#{}) " , config_section , reference , anchor_id ) ;
543
+ return format ! ( "[[{config_section }].{reference }](#{anchor_id }) " ) ;
548
544
}
549
545
}
550
546
}
@@ -577,7 +573,7 @@ fn process_hierarchical_lists(
577
573
let processed_content =
578
574
process_intralinks_with_context ( content, global_context, struct_name) ;
579
575
580
- result. push ( format ! ( "{}{}" , indent_html , processed_content ) ) ;
576
+ result. push ( format ! ( "{indent_html}{processed_content}" ) ) ;
581
577
} else {
582
578
// Process intra-links in non-bullet lines too
583
579
let processed_line = process_intralinks_with_context ( line, global_context, struct_name) ;
0 commit comments