docs: def main():
      """
      Starts the parser on the file given by the filename as the first
      argument on the command line.
      """
      from optparse import OptionParser, OptionGroup
      from os import sep
      from os.path import basename, getsize
      from sys import argv, exit as sysExit
      from chardet import detect
      from codecs import BOM_UTF8, open as codecsOpen
  
      def optParse():
          """
          Parses command line options.
  
          Generally we're supporting all the command line options that doxypy.py
          supports in an analogous way to make it easy to switch back and forth.
          We additionally support a top-level namespace argument that is used
          to trim away excess path information.
          """
  
          parser = OptionParser(prog=basename(argv[0]))
  
          parser.set_usage("%prog [options] filename")
          parser.add_option(
              "-a", "--autobrief",
              action="store_true", dest="autobrief",
              help="parse the docstring for @brief description and other information"
          )
          parser.add_option(
              "-c", "--autocode",
              action="store_true", dest="autocode",
              help="parse the docstring for code samples"
          )
          parser.add_option(
              "-n", "--ns",
              action="store", type="string", dest="topLevelNamespace",
              help="specify a top-level namespace that will be used to trim paths"
          )
          parser.add_option(
              "-t", "--tablength",
              action="store", type="int", dest="tablength", default=4,
              help="specify a tab length in spaces; only needed if tabs are used"
          )
          parser.add_option(
              "-s", "--stripinit",
              action="store_true", dest="stripinit",
              help="strip __init__ from namespace"
          )
          parser.add_option(
              "-O", "--object-respect",
              action="store_true", dest="object_respect",
              help="By default, doxypypy hides object class from class dependencies even if class inherits explictilty from objects (new-style class), this option disable this."
          )
          group = OptionGroup(parser, "Debug Options")
          group.add_option(
              "-d", "--debug",
              action="store_true", dest="debug",
              help="enable debug output on stderr"
          )
          parser.add_option_group(group)
  
          ## Parse options based on our definition.
          (options, filename) = parser.parse_args()
  
          # Just abort immediately if we are don't have an input file.
          if not filename:
              stderr.write("No filename given." + linesep)
              sysExit(-1)
  
          # Turn the full path filename into a full path module location.
          fullPathNamespace = filename[0].replace(sep, '.')[:-3]
          # Use any provided top-level namespace argument to trim off excess.
          realNamespace = fullPathNamespace
          if options.topLevelNamespace:
              namespaceStart = fullPathNamespace.find(options.topLevelNamespace)
              if namespaceStart >= 0:
                  realNamespace = fullPathNamespace[namespaceStart:]
          if options.stripinit:
              realNamespace = realNamespace.replace('.__init__', '')
          options.fullPathNamespace = realNamespace
  
          return options, filename[0]
  
      # Figure out what is being requested.
      (options, inFilename) = optParse()
  
      # Figure out encoding of input file.
      numOfSampleBytes = min(getsize(inFilename), 32)
      sampleBytes = open(inFilename, 'rb').read(numOfSampleBytes)
      sampleByteAnalysis = detect(sampleBytes)
      encoding = sampleByteAnalysis['encoding'] or 'ascii'
  
      # Switch to generic versions to strip the BOM automatically.
      if sampleBytes.startswith(BOM_UTF8):
          encoding = 'UTF-8-SIG'
      if encoding.startswith("UTF-16"):
          encoding = "UTF-16"
      elif encoding.startswith("UTF-32"):
          encoding = "UTF-32"
  
      # Read contents of input file.
      if encoding == 'ascii':
          inFile = open(inFilename)
      else:
          inFile = codecsOpen(inFilename, encoding=encoding)
      lines = inFile.readlines()
      inFile.close()
      # Create the abstract syntax tree for the input file.
      astWalker = AstWalker(lines, options, inFilename)
      astWalker.parseLines()
      # Output the modified source.
      print(astWalker.getLines())