def parse_commands(docstring):
    # type: (str) -> Generator[Tuple[List[str], List[str]], None, None]
    """Parse a docopt-style string for commands and subcommands.

    Args:
        docstring: A docopt-style string to parse. If the string is not a valid
            docopt-style string, it will not yield and values.

    Yields:
        All tuples of commands and subcommands found in the docopt docstring.
    """
    try:
        docopt.docopt(docstring, argv=())
    except (TypeError, docopt.DocoptLanguageError):
        return
    except docopt.DocoptExit:
        pass
    for command in _parse_section('usage', docstring):
        args = command.split()
        commands = []
        i = 0
        for i, arg in enumerate(args):
            if arg[0].isalpha() and not arg[0].isupper():
                commands.append(arg)
            else:
                break
        yield commands, args[i:]
def parse_commands ( docstring ) : try : docopt . docopt ( docstring , argv = ( ) ) except ( TypeError , docopt . DocoptLanguageError ) : return except docopt . DocoptExit : pass for command in _parse_section ( 'usage' , docstring ) : args = command . split ( ) commands = [ ] i = 0 for i , arg in enumerate ( args ) : if arg [ 0 ] . isalpha ( ) and not arg [ 0 ] . isupper ( ) : commands . append ( arg ) else : break yield commands , args [ i : ]
Parse a docopt-style string for commands and subcommands.

    Args:
        docstring: A docopt-style string to parse. If the string is not a valid
            docopt-style string, it will not yield and values.

    Yields:
        All tuples of commands and subcommands found in the docopt docstring.