Commit 0d289abc authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add --remap and --show-unchanged options to compare script.

parent d9c055bb
Loading
Loading
Loading
Loading
+40 −34
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ require "jsduck/util/json"

options = {
  :title => "Comparison of Ext 4.0.7 and Ext 4.1.1",
  :remap => {},
}

input_files = OptionParser.new do |opts|
@@ -30,6 +31,17 @@ input_files = OptionParser.new do |opts|
    options[:title] = text
  end

  opts.on("--show-unchanged", "To list classes that have not changed.",
    "By default only classes with changes are listed.") do
    options[:show_unchanged] = true
  end

  opts.on("--map=A:B", "Maps class A in old/classes/ to class B",
    "in new/classes/. For example --map Ext.Foo:Ext.NewFoo") do |pair|
    (a, b) = pair.split(/:/)
    options[:remap][a] = b
  end

  opts.on("-h", "--help", "Show this help message") do
    puts opts
    exit
@@ -229,22 +241,12 @@ old_classes = read_all_classes(options[:old_classes], :ignore_private)
new_classes = read_all_classes(options[:new_classes])
ignored_members = options[:ignore] ? read_ignored_members(options[:ignore]) : {}

# Explicit remapping of classes
remap = {
  "Array" => "Ext.Array",
  "Date" => "Ext.Date",
  "Function" => "Ext.Function",
  "Number" => "Ext.Number",
  "String" => "Ext.String",
  "Ext.supports" => "Ext.feature.has",
}

diff_data = []
old_classes.each_pair do |name, cls|
  # only go through classes, not alternate names
  if name == cls["name"]
    if remap[name]
      new_cls = new_classes[remap[name]]
    if options[:remap][name]
      new_cls = new_classes[options[:remap][name]]
    else
      new_cls = new_classes[name]
    end
@@ -301,8 +303,9 @@ EOHTML
html << "<ul>"
diff_data.sort! {|a, b| a[:name] <=> b[:name] }
diff_data.each do |cls|
  html << "<li>"
  if cls[:found]
    if cls[:diff].length > 0 || options[:show_unchanged]
      html << "<li>"
      new_name = (cls[:new_name] == cls[:name] ? "" : " --> " + cls[:new_name])
      diff_count = cls[:diff].length > 0 ? "(#{cls[:diff].length} changes)" : ""
      link = cls[:diff].length > 0? "<a href='#expand'>#{cls[:name]}</a>" : "<span style='color:green'>"+cls[:name]+'</span>'
@@ -327,11 +330,14 @@ diff_data.each do |cls|
        end
        html << "</ul>"
      end
      html << "</li>"
    end
  else
    html << "<li>"
    html << "<h2>" + cls[:name] + " <b>not found</b></h2>"
  end
    html << "</li>"
  end
end
html << "</ul>"

html << "<h2>Summary</h2>"