docs: def main(argv):
      """
      This parses a json manifest file containing list of webidl files and
      generates a file containing javascript arrays of json objects for
      each webidl file.
  
      usage: process_idl.py manifest.json ~/B2G
  
      The generated js file can then be included with the test app.
      """
  
      argparser = argparse.ArgumentParser()
      argparser.add_argument("manifest", help="Manifest file for the idl")
      argparser.add_argument("b2g", help="Path to b2g directory (e.g. ~/B2G")
      args = argparser.parse_args(argv[1:])
  
      with open(args.manifest, 'r') as f:
          manifest = json.loads(f.read())
  
      # import WebIDL using a path relative to the gecko tree
      sys.path.append(os.path.join(args.b2g, 'gecko', 'dom', 'bindings', 'parser'))
      import WebIDL
  
      parser = WebIDL.Parser()
  
      webidl_path = args.b2g
  
      # embed idl files in individual script tags
      for filename in manifest['files']:
          path = os.path.realpath(os.path.join(webidl_path, filename))
          with open(path, 'r') as f:
              parser.parse(''.join([line for line in f.readlines() if not line.startswith('#')]))
  
      results = parser.finish()
      tested = []
      untested = []
      for result in results:
          if isinstance(result, WebIDL.IDLImplementsStatement):
              continue
  
          if isinstance(result, WebIDL.IDLTypedefType):
              tested.append(jsonify_typedef(result))
              continue
  
          if result.isInterface():
  
              if result.isExternal():
                  continue
  
              print(result.identifier.name)
              if result.identifier.name in manifest['untested']:
                  untested.append(jsonify_interface(result))
              else:
                  tested.append(jsonify_interface(result))
  
      with open('merged_idl.js', 'w') as merged:
          merged.write('TESTED_IDL=')
          merged.write(json.dumps(tested))
          merged.write(';\n')
          merged.write('UNTESTED_IDL=')
          merged.write(json.dumps(untested))
          merged.write(';\n')