def _format_command(ctx, show_nested):
"""Format the output of `click.Command`."""
# description
for line in _format_description(ctx):
yield line
yield '.. program:: {}'.format(ctx.command_path)
# usage
for line in _format_usage(ctx):
yield line
# options
lines = list(_format_options(ctx))
if lines:
# we use rubric to provide some separation without exploding the table
# of contents
yield '.. rubric:: Options'
yield ''
for line in lines:
yield line
# arguments
lines = list(_format_arguments(ctx))
if lines:
yield '.. rubric:: Arguments'
yield ''
for line in lines:
yield line
# environment variables
lines = list(_format_envvars(ctx))
if lines:
yield '.. rubric:: Environment variables'
yield ''
for line in lines:
yield line
# if we're nesting commands, we need to do this slightly differently
if show_nested:
return
commands = sorted(getattr(ctx.command, 'commands', {}).items())
if commands:
yield '.. rubric:: Commands'
yield ''
for command in commands:
for line in _format_subcommand(command):
yield line
yield ''
评论列表
文章目录