Esempio n. 1
0
def main():
  # Prevent windows from using cygwin python.
  if (sys.platform == "cygwin"):
    sys.exit("Building docs not supported for cygwin python. Please run the "
             "build.sh script instead, which uses depot_tools python.")

  parser = OptionParser()
  parser.add_option("--dump-render-tree-path", dest="dump_render_tree_path",
                    metavar="PATH",
                    help="path to DumpRenderTree executable")
  parser.add_option("--page-name", dest="page_name", metavar="PAGE",
                    help="only generate docs for PAGE.html")
  parser.add_option("--nozip", dest="zips", action="store_false",
                    help="do not generate zip files for samples",
                    default=True)
  options, args = parser.parse_args()

  if (options.dump_render_tree_path and
      os.path.isfile(options.dump_render_tree_path)):
    dump_render_tree = options.dump_render_tree_path
  else:
    dump_render_tree = FindDumpRenderTree()

  # Load the manifest of existing API Methods
  api_manifest = ApiManifest([_extension_api_json, _devtools_api_json])

  # Read static file names
  static_names = GetStaticFileNames()

  # Read module names
  module_names = api_manifest.getModuleNames()

  # All pages to generate
  page_names = static_names | module_names

  # Allow the user to render a single page if they want
  if options.page_name:
    if options.page_name in page_names:
      page_names = [options.page_name]
    else:
      raise Exception("--page-name argument must be one of %s." %
                      ', '.join(sorted(page_names)))

  # Render a manifest file containing metadata about all the extension samples
  samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest)
  samples_manifest.writeToFile(_samples_json)

  # Write zipped versions of the samples listed in the manifest to the
  # filesystem, unless the user has disabled it
  if options.zips:
    modified_zips = samples_manifest.writeZippedSamples()
  else:
    modified_zips = []

  modified_files = RenderPages(page_names, dump_render_tree)
  modified_files.extend(modified_zips)

  if len(modified_files) == 0:
    print "Output files match existing files. No changes made."
  else:
    print ("ATTENTION: EXTENSION DOCS HAVE CHANGED\n" +
           "The following files have been modified and should be checked\n" +
           "into source control (ideally in the same changelist as the\n" +
           "underlying files that resulting in their changing).")
    for f in modified_files:
      print " * %s" % f

  # Hack. Sleep here, otherwise windows doesn't properly close the debug.log
  # and the os.remove will fail with a "Permission denied".
  time.sleep(1)
  debug_log = os.path.normpath(_build_dir + "/" + "debug.log")
  if (os.path.isfile(debug_log)):
    os.remove(debug_log)

  if 'EX_OK' in dir(os):
    return os.EX_OK
  else:
    return 0
Esempio n. 2
0
def main():
  # Prevent windows from using cygwin python.
  if (sys.platform == "cygwin"):
    sys.exit("Building docs not supported for cygwin python. Please run the "
             "build.sh script instead, which uses depot_tools python.")

  parser = OptionParser()
  parser.add_option("--dump-render-tree-path", dest="dump_render_tree_path",
                    metavar="PATH",
                    help="path to DumpRenderTree executable")
  parser.add_option("--page-name", dest="page_name", metavar="PAGE",
                    help="only generate docs for PAGE.html")
  parser.add_option("--nozip", dest="zips", action="store_false",
                    help="do not generate zip files for samples",
                    default=True)
  options, args = parser.parse_args()

  if (options.dump_render_tree_path and
      os.path.isfile(options.dump_render_tree_path)):
    dump_render_tree = options.dump_render_tree_path
  else:
    dump_render_tree = FindDumpRenderTree()

  # Load the manifest of existing API Methods
  api_manifest = ApiManifest([_extension_api_json, _devtools_api_json])

  # Read static file names
  static_names = GetStaticFileNames()

  # Read module names
  module_names = api_manifest.getModuleNames()

  # All pages to generate
  page_names = static_names | module_names

  # Allow the user to render a single page if they want
  if options.page_name:
    if options.page_name in page_names:
      page_names = [options.page_name]
    else:
      raise Exception("--page-name argument must be one of %s." %
                      ', '.join(sorted(page_names)))

  # Render a manifest file containing metadata about all the extension samples
  samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest)
  samples_manifest.writeToFile(_samples_json)

  # Write zipped versions of the samples listed in the manifest to the
  # filesystem, unless the user has disabled it
  if options.zips:
    modified_zips = samples_manifest.writeZippedSamples()
  else:
    modified_zips = []

  modified_files = RenderPages(page_names, dump_render_tree)
  modified_files.extend(modified_zips)

  if len(modified_files) == 0:
    print "Output files match existing files. No changes made."
  else:
    print ("ATTENTION: EXTENSION DOCS HAVE CHANGED\n" +
           "The following files have been modified and should be checked\n" +
           "into source control (ideally in the same changelist as the\n" +
           "underlying files that resulting in their changing).")
    for f in modified_files:
      print " * %s" % f

  # Hack. Sleep here, otherwise windows doesn't properly close the debug.log
  # and the os.remove will fail with a "Permission denied".
  time.sleep(1)
  debug_log = os.path.normpath(_build_dir + "/" + "debug.log")
  if (os.path.isfile(debug_log)):
    os.remove(debug_log)

  if 'EX_OK' in dir(os):
    return os.EX_OK
  else:
    return 0
Esempio n. 3
0
def main():
    # Prevent windows from using cygwin python.
    if (sys.platform == "cygwin"):
        sys.exit(
            "Building docs not supported for cygwin python. Please run the "
            "build.sh script instead, which uses depot_tools python.")

    parser = OptionParser()
    parser.add_option("--dump-render-tree-path",
                      dest="dump_render_tree_path",
                      metavar="PATH",
                      help="path to DumpRenderTree executable")
    parser.add_option("--page-name",
                      dest="page_name",
                      metavar="PAGE",
                      help="only generate docs for PAGE.html")
    parser.add_option("--nozip",
                      dest="zips",
                      action="store_false",
                      help="do not generate zip files for samples",
                      default=True)
    options, args = parser.parse_args()

    if (options.dump_render_tree_path
            and os.path.isfile(options.dump_render_tree_path)):
        dump_render_tree = options.dump_render_tree_path
    else:
        dump_render_tree = FindDumpRenderTree()

    # Load the manifest of existing API Methods
    api_manifest = ApiManifest(_extension_api_json_schemas,
                               _extension_api_idl_schemas)

    # Write temporary JSON files based on the IDL inputs
    api_manifest.generateJSONFromIDL()

    # Render a manifest file containing metadata about all the extension samples
    samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest)
    samples_manifest.writeToFile(_samples_json)

    # Write zipped versions of the samples listed in the manifest to the
    # filesystem, unless the user has disabled it
    modified_files = []
    if options.zips:
        modified_files.extend(samples_manifest.writeZippedSamples())

    doc_families = ["extensions", "apps"]
    for family in doc_families:
        modified_files.extend(
            RenderPages(family, dump_render_tree, options.page_name))

    if len(modified_files) == 0:
        print "Output files match existing files. No changes made."
    else:
        print(
            "ATTENTION: EXTENSION DOCS HAVE CHANGED\n" +
            "The following files have been modified and should be checked\n" +
            "into source control (ideally in the same changelist as the\n" +
            "underlying files that resulting in their changing).")
        for f in modified_files:
            print " * %s" % f

    # Hack. Sleep here, otherwise windows doesn't properly close the debug.log
    # and the os.remove will fail with a "Permission denied".
    time.sleep(1)
    debug_log = os.path.normpath(_build_dir + "/" + "debug.log")
    if (os.path.isfile(debug_log)):
        os.remove(debug_log)

    # Cleanup our temporary IDL->JSON files
    api_manifest.cleanupGeneratedFiles()

    if 'EX_OK' in dir(os):
        return os.EX_OK
    else:
        return 0
Esempio n. 4
0
def main():
    # Prevent windows from using cygwin python.
    if sys.platform == "cygwin":
        sys.exit(
            "Building docs not supported for cygwin python. Please run the "
            "build.sh script instead, which uses depot_tools python."
        )

    parser = OptionParser()
    parser.add_option(
        "--dump-render-tree-path",
        dest="dump_render_tree_path",
        metavar="PATH",
        help="path to DumpRenderTree executable",
    )
    parser.add_option("--page-name", dest="page_name", metavar="PAGE", help="only generate docs for PAGE.html")
    parser.add_option(
        "--nozip", dest="zips", action="store_false", help="do not generate zip files for samples", default=True
    )
    options, args = parser.parse_args()

    if options.dump_render_tree_path and os.path.isfile(options.dump_render_tree_path):
        dump_render_tree = options.dump_render_tree_path
    else:
        dump_render_tree = FindDumpRenderTree()

    # Load the manifest of existing API Methods
    api_manifest = ApiManifest(_extension_api_json_schemas, _extension_api_idl_schemas)

    # Write temporary JSON files based on the IDL inputs
    api_manifest.generateJSONFromIDL()

    # Render a manifest file containing metadata about all the extension samples
    samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest)
    samples_manifest.writeToFile(_samples_json)

    # Write zipped versions of the samples listed in the manifest to the
    # filesystem, unless the user has disabled it
    modified_files = []
    if options.zips:
        modified_files.extend(samples_manifest.writeZippedSamples())

    doc_families = ["extensions", "apps"]
    for family in doc_families:
        modified_files.extend(RenderPages(family, dump_render_tree, options.page_name))

    if len(modified_files) == 0:
        print "Output files match existing files. No changes made."
    else:
        print (
            "ATTENTION: EXTENSION DOCS HAVE CHANGED\n"
            + "The following files have been modified and should be checked\n"
            + "into source control (ideally in the same changelist as the\n"
            + "underlying files that resulting in their changing)."
        )
        for f in modified_files:
            print " * %s" % f

    # Hack. Sleep here, otherwise windows doesn't properly close the debug.log
    # and the os.remove will fail with a "Permission denied".
    time.sleep(1)
    debug_log = os.path.normpath(_build_dir + "/" + "debug.log")
    if os.path.isfile(debug_log):
        os.remove(debug_log)

    # Cleanup our temporary IDL->JSON files
    api_manifest.cleanupGeneratedFiles()

    if "EX_OK" in dir(os):
        return os.EX_OK
    else:
        return 0