ext.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sphinx-click 作者: click-contrib 项目源码 文件源码
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 ''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号