def _format_command(ctx, show_nested, commands=None):
    if getattr(ctx.command, 'hidden', False):
        return
    for line in _format_description(ctx):
        yield line
    yield '.. program:: {}'.format(ctx.command_path)
    for line in _format_usage(ctx):
        yield line
    lines = list(_format_options(ctx))
    if lines:
        yield '.. rubric:: Options'
        yield ''
    for line in lines:
        yield line
    lines = list(_format_arguments(ctx))
    if lines:
        yield '.. rubric:: Arguments'
        yield ''
    for line in lines:
        yield line
    lines = list(_format_envvars(ctx))
    if lines:
        yield '.. rubric:: Environment variables'
        yield ''
    for line in lines:
        yield line
    if show_nested:
        return
    commands = _filter_commands(ctx, commands)
    if commands:
        yield '.. rubric:: Commands'
        yield ''
    for command in commands:
        if CLICK_VERSION >= (7, 0):
            if command.hidden:
                continue
        for line in _format_subcommand(command):
            yield line
        yield ''