@@ -38,6 +38,7 @@ def _get_help_record(opt):
3838
3939 [1] http://www.sphinx-doc.org/en/stable/domains.html#directive-option
4040 """
41+
4142 def _write_opts (opts ):
4243 rv , _ = click .formatting .join_options (opts )
4344 if not opt .is_flag and not opt .count :
@@ -57,9 +58,14 @@ def _write_opts(opts):
5758 # documentation thus needs a manually written string.
5859 extra .append ('default: %s' % opt .show_default )
5960 else :
60- extra .append ('default: %s' %
61- (', ' .join ('%s' % d for d in opt .default ) if isinstance (
62- opt .default , (list , tuple )) else opt .default , ))
61+ extra .append (
62+ 'default: %s'
63+ % (
64+ ', ' .join ('%s' % d for d in opt .default )
65+ if isinstance (opt .default , (list , tuple ))
66+ else opt .default ,
67+ )
68+ )
6369 if opt .required :
6470 extra .append ('required' )
6571 if extra :
@@ -84,9 +90,9 @@ def _format_description(ctx):
8490 return
8591
8692 bar_enabled = False
87- for line in statemachine .string2lines (help_string ,
88- tab_width = 4 ,
89- convert_whitespace = True ):
93+ for line in statemachine .string2lines (
94+ help_string , tab_width = 4 , convert_whitespace = True
95+ ):
9096 if line == '\b ' :
9197 bar_enabled = True
9298 continue
@@ -113,18 +119,19 @@ def _format_option(opt):
113119 yield '.. option:: {}' .format (opt [0 ])
114120 if opt [1 ]:
115121 yield ''
116- for line in statemachine .string2lines (opt [ 1 ],
117- tab_width = 4 ,
118- convert_whitespace = True ):
122+ for line in statemachine .string2lines (
123+ opt [ 1 ], tab_width = 4 , convert_whitespace = True
124+ ):
119125 yield _indent (line )
120126
121127
122128def _format_options (ctx ):
123129 """Format all `click.Option` for a `click.Command`."""
124130 # the hidden attribute is part of click 7.x only hence use of getattr
125131 params = [
126- x for x in ctx .command .params
127- if isinstance (x , click .Option ) and not getattr (x , 'hidden' , False )
132+ param
133+ for param in ctx .command .params
134+ if isinstance (param , click .Option ) and not getattr (param , 'hidden' , False )
128135 ]
129136
130137 for param in params :
@@ -137,9 +144,11 @@ def _format_argument(arg):
137144 """Format the output of a `click.Argument`."""
138145 yield '.. option:: {}' .format (arg .human_readable_name )
139146 yield ''
140- yield _indent ('{} argument{}' .format (
141- 'Required' if arg .required else 'Optional' ,
142- '(s)' if arg .nargs != 1 else '' ))
147+ yield _indent (
148+ '{} argument{}' .format (
149+ 'Required' if arg .required else 'Optional' , '(s)' if arg .nargs != 1 else ''
150+ )
151+ )
143152
144153
145154def _format_arguments (ctx ):
@@ -195,9 +204,9 @@ def _format_subcommand(command):
195204
196205 if short_help :
197206 yield ''
198- for line in statemachine .string2lines (short_help ,
199- tab_width = 4 ,
200- convert_whitespace = True ):
207+ for line in statemachine .string2lines (
208+ short_help , tab_width = 4 , convert_whitespace = True
209+ ):
201210 yield _indent (line )
202211
203212
@@ -311,39 +320,39 @@ def _load_module(self, module_path):
311320 module_name , attr_name = module_path .split (':' , 1 )
312321 except ValueError : # noqa
313322 raise self .error (
314- '"{}" is not of format "module:parser"' .format (module_path ))
323+ '"{}" is not of format "module:parser"' .format (module_path )
324+ )
315325
316326 try :
317327 mod = __import__ (module_name , globals (), locals (), [attr_name ])
318328 except (Exception , SystemExit ) as exc : # noqa
319- err_msg = 'Failed to import "{}" from "{}". ' .format (
320- attr_name , module_name )
329+ err_msg = 'Failed to import "{}" from "{}". ' .format (attr_name , module_name )
321330 if isinstance (exc , SystemExit ):
322331 err_msg += 'The module appeared to call sys.exit()'
323332 else :
324333 err_msg += 'The following exception was raised:\n {}' .format (
325- traceback .format_exc ())
334+ traceback .format_exc ()
335+ )
326336
327337 raise self .error (err_msg )
328338
329339 if not hasattr (mod , attr_name ):
330- raise self .error ('Module "{}" has no attribute "{}"' .format (
331- module_name , attr_name ))
340+ raise self .error (
341+ 'Module "{}" has no attribute "{}"' .format (module_name , attr_name )
342+ )
332343
333344 parser = getattr (mod , attr_name )
334345
335346 if not isinstance (parser , click .BaseCommand ):
336- raise self .error ('"{}" of type "{}" is not derived from '
337- '"click.BaseCommand"' .format (
338- type (parser ), module_path ))
347+ raise self .error (
348+ '"{}" of type "{}" is not derived from '
349+ '"click.BaseCommand"' .format (type (parser ), module_path )
350+ )
339351 return parser
340352
341- def _generate_nodes (self ,
342- name ,
343- command ,
344- parent = None ,
345- show_nested = False ,
346- commands = None ):
353+ def _generate_nodes (
354+ self , name , command , parent = None , show_nested = False , commands = None
355+ ):
347356 """Generate the relevant Sphinx nodes.
348357
349358 Format a `click.Group` or `click.Command`.
@@ -367,7 +376,8 @@ def _generate_nodes(self,
367376 '' ,
368377 nodes .title (text = name ),
369378 ids = [nodes .make_id (ctx .command_path )],
370- names = [nodes .fully_normalize_name (ctx .command_path )])
379+ names = [nodes .fully_normalize_name (ctx .command_path )],
380+ )
371381
372382 # Summary
373383
@@ -387,8 +397,8 @@ def _generate_nodes(self,
387397 commands = _filter_commands (ctx , commands )
388398 for command in commands :
389399 section .extend (
390- self ._generate_nodes (command .name , command , ctx ,
391- show_nested ) )
400+ self ._generate_nodes (command .name , command , ctx , show_nested )
401+ )
392402
393403 return [section ]
394404
@@ -404,8 +414,7 @@ def run(self):
404414 show_nested = 'show-nested' in self .options
405415 commands = self .options .get ('commands' )
406416
407- return self ._generate_nodes (prog_name , command , None , show_nested ,
408- commands )
417+ return self ._generate_nodes (prog_name , command , None , show_nested , commands )
409418
410419
411420def setup (app ):
0 commit comments