@@ -185,6 +185,8 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
185185
186186 // Do not display options for commands with children
187187 if !has_subcommands {
188+ let name_key = name. replace ( ' ' , "-" ) ;
189+
188190 // Display positional arguments
189191 let mut arguments = command
190192 . get_positionals ( )
@@ -196,10 +198,11 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
196198 output. push_str ( "<dl class=\" cli-reference\" >" ) ;
197199
198200 for arg in arguments {
199- output. push_str ( "<dt>" ) ;
201+ let id = format ! ( "{name_key}--{}" , arg. get_id( ) ) ;
202+ output. push_str ( & format ! ( "<dt id=\" {id}\" >" ) ) ;
200203 output. push_str ( & format ! (
201- "<code>{}</code>" ,
202- arg. get_id( ) . to_string( ) . to_uppercase( )
204+ "<a href= \" #{id} \" < code>{}</code></a >" ,
205+ arg. get_id( ) . to_string( ) . to_uppercase( ) ,
203206 ) ) ;
204207 output. push_str ( "</dt>" ) ;
205208 if let Some ( help) = arg. get_long_help ( ) . or_else ( || arg. get_help ( ) ) {
@@ -225,9 +228,10 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
225228 output. push_str ( "<dl class=\" cli-reference\" >" ) ;
226229 for opt in options {
227230 let Some ( long) = opt. get_long ( ) else { continue } ;
231+ let id = format ! ( "{name_key}--{long}" ) ;
228232
229- output. push_str ( "<dt>" ) ;
230- output. push_str ( & format ! ( "<code>--{long}</code>" ) ) ;
233+ output. push_str ( & format ! ( "<dt id= \" {id} \" >" ) ) ;
234+ output. push_str ( & format ! ( "<a href= \" #{id} \" >< code>--{long}</code></a>" , ) ) ;
231235 if let Some ( short) = opt. get_short ( ) {
232236 output. push_str ( & format ! ( ", <code>-{short}</code>" ) ) ;
233237 }
0 commit comments