Created
June 5, 2014 06:10
-
-
Save oleganza/ecee229a97081e9357f6 to your computer and use it in GitHub Desktop.
Strip away "method->property" updates from iOS/OSX API diffs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Oleg Andreev @oleganza | |
# | |
# This is a script that strips away all lines about converting methods to properties. | |
# Filtered file is easier to read to find what's new. | |
# | |
# 1. Save html file with API diff. | |
# 2. Run filter-api-diff.rb <name-of-the-file.html> | |
# 3. Open <name-of-the-file.html>-filtered.html in Safari. | |
# | |
# This script adds absolute URLs for stylesheets, no worries about them. | |
def main | |
if ARGV[0] | |
filter ARGV[0] | |
else | |
filter("ios8-api-diff.html") | |
filter("osx10-api-diff.html") | |
end | |
end | |
class String | |
def capitalize | |
self[0,1].upcase + self[1..-1] | |
end | |
end | |
def filter(filename) | |
d = File.read(filename) | |
lines = d.split("\n") | |
new_lines = [] | |
removed_selectors_diff = {} # selector -> index | |
lines.each_with_index do |line, idx| | |
if line =~ /<div class='headerName'/ | |
# reset per header file | |
removed_selectors_diff = {} | |
end | |
if line =~ %r{</head>} | |
new_lines << %{<link rel="stylesheet" type="text/css" href="https://developer.apple.com/library/prerelease/mac/Resources/987/CSS/screen.css" /> | |
<link rel="stylesheet" type="text/css" href="https://developer.apple.com/library/prerelease/mac/Resources/987/CSS/feedback.css" /> | |
<link rel="stylesheet" type="text/css" href="https://developer.apple.com/library/prerelease/mac/documentation/General/Reference/APIDiffsMacOSX10_10SeedDiff/Resources/CSS/apidiff.css" /> | |
} | |
end | |
new_lines << line | |
if line =~ %r{<span class="diffStatus">Removed</span>} | |
if line =~ %r{>-\[([^\]<>\n]+)\]<} | |
#puts "REMOVED: #{$1}" | |
removed_selectors_diff[$1] = new_lines.size - 1 | |
else | |
#puts "WARNING: Can't find selector in this removed API: #{line}" | |
end | |
elsif line =~ %r{<span class="diffStatus">Added</span>} | |
if line =~ %r{<!--a -->(\w+\.\w+)<!--/a-->} | |
api = $1 | |
cls,meth = api.split(".") | |
getter = "#{cls} #{meth}" | |
boolgetter = "#{cls} is#{meth.capitalize}" | |
setter = "#{cls} set#{meth.capitalize}:" | |
matched = false | |
if i = removed_selectors_diff[getter] | |
matched = true | |
puts "REMOVED: #{getter}" | |
new_lines[i] = "" | |
end | |
if i = removed_selectors_diff[boolgetter] | |
matched = true | |
puts "REMOVED: #{boolgetter}" | |
new_lines[i] = "" | |
end | |
if i = removed_selectors_diff[setter] | |
matched = true | |
puts "REMOVED: #{setter}" | |
new_lines[i] = "" | |
end | |
if matched | |
puts "REMOVED: #{api}" | |
puts "------------------------------" | |
new_lines.pop # simply skip this line | |
end | |
else | |
end | |
#puts line | |
end | |
#puts line | |
end | |
File.open(filename + "-filtered.html", "w") {|f| f.write(new_lines.join("\n")) } | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment