parameters: (doc, argv=None, help=True, version=None, options_first=False)
docstring: Parse `argv` based on command-line interface described in `doc`.
  
      `docopt` creates your command-line interface based on its
      description that you pass as `doc`. Such description can contain
      --options, <positional-argument>, commands, which could be
      [optional], (required), (mutually | exclusive) or repeated...
  
      Parameters
      ----------
      doc : str
          Description of your command-line interface.
      argv : list of str, optional
          Argument vector to be parsed. sys.argv[1:] is used if not
          provided.
      help : bool (default: True)
          Set to False to disable automatic help on -h or --help
          options.
      version : any object
          If passed, the object will be printed if --version is in
          `argv`.
      options_first : bool (default: False)
          Set to True to require options precede positional arguments,
          i.e. to forbid options and positional arguments intermix.
  
      Returns
      -------
      args : dict
          A dictionary, where keys are names of command-line elements
          such as e.g. "--verbose" and "<path>", and values are the
          parsed values of those elements.
  
      Example
      -------
      >>> from docopt import docopt
      >>> doc = '''
      ... Usage:
      ...     my_program tcp <host> <port> [--timeout=<seconds>]
      ...     my_program serial <port> [--baud=<n>] [--timeout=<seconds>]
      ...     my_program (-h | --help | --version)
      ...
      ... Options:
      ...     -h, --help  Show this screen and exit.
      ...     --baud=<n>  Baudrate [default: 9600]
      ... '''
      >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30']
      >>> docopt(doc, argv)
      {'--baud': '9600',
       '--help': False,
       '--timeout': '30',
       '--version': False,
       '<host>': '127.0.0.1',
       '<port>': '80',
       'serial': False,
       'tcp': True}
  
      See also
      --------
      * For video introduction see http://docopt.org
      * Full documentation is available in README.rst as well as online
        at https://github.com/docopt/docopt#readme
docstring_summary: Parse `argv` based on command-line interface described in `doc`.
docstring_tokens: Parse argv based on command - line interface described in doc .
function: def docopt(doc, argv=None, help=True, version=None, options_first=False):
      """Parse `argv` based on command-line interface described in `doc`.
  
      `docopt` creates your command-line interface based on its
      description that you pass as `doc`. Such description can contain
      --options, <positional-argument>, commands, which could be
      [optional], (required), (mutually | exclusive) or repeated...
  
      Parameters
      ----------
      doc : str
          Description of your command-line interface.
      argv : list of str, optional
          Argument vector to be parsed. sys.argv[1:] is used if not
          provided.
      help : bool (default: True)
          Set to False to disable automatic help on -h or --help
          options.
      version : any object
          If passed, the object will be printed if --version is in
          `argv`.
      options_first : bool (default: False)
          Set to True to require options precede positional arguments,
          i.e. to forbid options and positional arguments intermix.
  
      Returns
      -------
      args : dict
          A dictionary, where keys are names of command-line elements
          such as e.g. "--verbose" and "<path>", and values are the
          parsed values of those elements.
  
      Example
      -------
      >>> from docopt import docopt
      >>> doc = '''
      ... Usage:
      ...     my_program tcp <host> <port> [--timeout=<seconds>]
      ...     my_program serial <port> [--baud=<n>] [--timeout=<seconds>]
      ...     my_program (-h | --help | --version)
      ...
      ... Options:
      ...     -h, --help  Show this screen and exit.
      ...     --baud=<n>  Baudrate [default: 9600]
      ... '''
      >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30']
      >>> docopt(doc, argv)
      {'--baud': '9600',
       '--help': False,
       '--timeout': '30',
       '--version': False,
       '<host>': '127.0.0.1',
       '<port>': '80',
       'serial': False,
       'tcp': True}
  
      See also
      --------
      * For video introduction see http://docopt.org
      * Full documentation is available in README.rst as well as online
        at https://github.com/docopt/docopt#readme
  
      """
      argv = sys.argv[1:] if argv is None else argv
  
      usage_sections = parse_section('usage:', doc)
      if len(usage_sections) == 0:
          raise DocoptLanguageError('"usage:" (case-insensitive) not found.')
      if len(usage_sections) > 1:
          raise DocoptLanguageError('More than one "usage:" (case-insensitive).')
      DocoptExit.usage = usage_sections[0]
  
      options = parse_defaults(doc)
      pattern = parse_pattern(formal_usage(DocoptExit.usage), options)
      # [default] syntax for argument is disabled
      #for a in pattern.flat(Argument):
      #    same_name = [d for d in arguments if d.name == a.name]
      #    if same_name:
      #        a.value = same_name[0].value
      argv = parse_argv(Tokens(argv), list(options), options_first)
      pattern_options = set(pattern.flat(Option))
      for options_shortcut in pattern.flat(OptionsShortcut):
          doc_options = parse_defaults(doc)
          options_shortcut.children = list(set(doc_options) - pattern_options)
          #if any_options:
          #    options_shortcut.children += [Option(o.short, o.long, o.argcount)
          #                    for o in argv if type(o) is Option]
      extras(help, version, argv, doc)
      matched, left, collected = pattern.fix().match(argv)
      if matched and left == []:  # better error message if left?
          return Dict((a.name, a.value) for a in (pattern.flat() + collected))
      raise DocoptExit()
function_tokens: def docopt ( doc , argv = None , help = True , version = None , options_first = False ) : argv = sys . argv [ 1 : ] if argv is None else argv usage_sections = parse_section ( 'usage:' , doc ) if len ( usage_sections ) == 0 : raise DocoptLanguageError ( '"usage:" (case-insensitive) not found.' ) if len ( usage_sections ) > 1 : raise DocoptLanguageError ( 'More than one "usage:" (case-insensitive).' ) DocoptExit . usage = usage_sections [ 0 ] options = parse_defaults ( doc ) pattern = parse_pattern ( formal_usage ( DocoptExit . usage ) , options ) # [default] syntax for argument is disabled #for a in pattern.flat(Argument): #    same_name = [d for d in arguments if d.name == a.name] #    if same_name: #        a.value = same_name[0].value argv = parse_argv ( Tokens ( argv ) , list ( options ) , options_first ) pattern_options = set ( pattern . flat ( Option ) ) for options_shortcut in pattern . flat ( OptionsShortcut ) : doc_options = parse_defaults ( doc ) options_shortcut . children = list ( set ( doc_options ) - pattern_options ) #if any_options: #    options_shortcut.children += [Option(o.short, o.long, o.argcount) #                    for o in argv if type(o) is Option] extras ( help , version , argv , doc ) matched , left , collected = pattern . fix ( ) . match ( argv ) if matched and left == [ ] : # better error message if left? return Dict ( ( a . name , a . value ) for a in ( pattern . flat ( ) + collected ) ) raise DocoptExit ( )