@@ -177,83 +177,74 @@ def process(
177177 """Convert a Click command to a Markdown element."""
178178 actual_name = override_name or command ["name" ]
179179 full_name = prefix + " " + actual_name if prefix and actual_name else actual_name
180- cli_to_doc [full_name ] = Section (
181- (
182- Paragraph (InlineText (command ["help" ])) if command ["help" ] else Empty (),
183- Section (
184- (
185- Header (3 , InlineText ("Usage" )),
186- CodeBlock (
187- "$"
188- + (" " + prefix .strip () if prefix else "" )
189- + " "
190- + actual_name .strip ()
191- + (
192- " [OPTIONS]"
193- if command ["params" ]
194- and any (
195- param .get ("param_type_name" ) != "argument"
196- for param in command ["params" ]
197- )
198- else ""
199- )
200- + (
201- " " + " " .join (arguments )
202- if (
203- arguments := [
204- param ["name" ].upper ()
205- for param in command ["params" ]
206- if param .get ("param_type_name" ) == "argument"
207- and param ["name" ]
208- ]
209- )
210- else ""
211- ),
212- language = "console" ,
213- ),
180+ cli_to_doc [full_name ] = Section ((
181+ Paragraph (InlineText (command ["help" ])) if command ["help" ] else Empty (),
182+ Section ((
183+ Header (3 , InlineText ("Usage" )),
184+ CodeBlock (
185+ "$"
186+ + (" " + prefix .strip () if prefix else "" )
187+ + " "
188+ + actual_name .strip ()
189+ + (
190+ " [OPTIONS]"
191+ if command ["params" ]
192+ and any (
193+ param .get ("param_type_name" ) != "argument"
194+ for param in command ["params" ]
195+ )
196+ else ""
214197 )
215- )
216- if actual_name
217- else Empty (),
218- Section (
219- (
220- Header (3 , InlineText ("Options" )),
221- List (
222- tuple (
223- InlineTextCollection (
198+ + (
199+ " " + " " .join (arguments )
200+ if (
201+ arguments := [
202+ param ["name" ].upper ()
203+ for param in command ["params" ]
204+ if param .get ("param_type_name" ) == "argument"
205+ and param ["name" ]
206+ ]
207+ )
208+ else ""
209+ ),
210+ language = "console" ,
211+ ),
212+ ))
213+ if actual_name
214+ else Empty (),
215+ Section ((
216+ Header (3 , InlineText ("Options" )),
217+ List (
218+ tuple (
219+ InlineTextCollection ((
220+ InlineCode (
221+ ", " .join (param ["opts" ])
222+ + (
223+ " / " + ", " .join (param ["secondary_opts" ])
224+ if param ["secondary_opts" ]
225+ else ""
226+ )
227+ + (
224228 (
225- InlineCode (
226- ", " .join (param ["opts" ])
227- + (
228- " / " + ", " .join (param ["secondary_opts" ])
229- if param ["secondary_opts" ]
230- else ""
231- )
232- + (
233- (
234- " " + param ["type" ]["name" ].upper ()
235- if param ["type" ]["name" ] != "boolean"
236- else ""
237- )
238- if (choices := param ["type" ].get ("choices" ))
239- is None
240- else " [" + "|" .join (choices ) + "]"
241- )
242- ),
243- InlineText (": " + option_help ),
229+ " " + param ["type" ]["name" ].upper ()
230+ if param ["type" ]["name" ] != "boolean"
231+ else ""
244232 )
233+ if (choices := param ["type" ].get ("choices" )) is None
234+ else " [" + "|" .join (choices ) + "]"
245235 )
246- for param in command ["params" ]
247- if (option_help := param .get ("help" )) is not None
248236 ),
249- ordered = False ,
250- ),
251- )
252- )
253- if command ["params" ]
254- else Empty (),
255- )
256- ).into_text ()
237+ InlineText (": " + option_help ),
238+ ))
239+ for param in command ["params" ]
240+ if (option_help := param .get ("help" )) is not None
241+ ),
242+ ordered = False ,
243+ ),
244+ ))
245+ if command ["params" ]
246+ else Empty (),
247+ )).into_text ()
257248 for name , sub_command in sort_subcommands (command .get ("commands" , {})).items ():
258249 process (
259250 sub_command ,
0 commit comments