Created
December 4, 2012 05:56
-
-
Save oa414/4201117 to your computer and use it in GitHub Desktop.
把AndroidSDK的文档里面一句JavaScript注释掉,提高打开的速度
This file contains hidden or 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
| #=================================================================== | |
| # FileName: changeSDKJS.rb | |
| # Author: Lin Xiangyu | |
| # Email: [email protected] | |
| # WebSite: http://linxiangyu.info | |
| # CreateTime: 2012.12.04 | |
| #=================================================================== | |
| # Android SDK里面有自带的文档,但是在大陆打开很慢,原因是会去加载一个jsapi,然后被墙 | |
| # <script src="http://www.google.com/jsapi" type="text/javascript"></script> | |
| # 把SDK里面的HTML文档里面这句话注释掉就行了 | |
| # 我是从http://www.douban.com/note/250736841/ 和 http://my.oschina.net/willedward/blog/91260 发现的原因,他们用Java写了一份 | |
| # 我写了一个Ruby版本的,在我的Mac OS X10.8 + Ruby 1.9.3下能正常运行 | |
| # when you open the document of Android SDK docs, it will require a JavaScript: <script src="http://www.google.com/jsapi" type="text/javascript"></script> | |
| # This script can help you comment this statement of SDK document and improve the speed of openning the docs | |
| # Usage: ruby scriptname SDKpath | |
| # Example: ruby changeSDKJS.rb ~/program/android-sdk-macosx/ | |
| require 'find' | |
| $jsline = %Q|<script src="http://www.google.com/jsapi" type="text/javascript"></script>| | |
| $jscomment = "<!--" + $jsline + "-->" | |
| def process(path) | |
| puts "Processing #{path}" | |
| newfile = File.new(path + 'tmp', 'w') | |
| File.open(path) do |oldfile| | |
| while line = oldfile.gets | |
| if line.include? $jsline | |
| puts "FIND" | |
| newfile.puts $jscomment | |
| else | |
| newfile.puts line | |
| end | |
| end | |
| end | |
| File.delete(path) | |
| File.rename(path + 'tmp', path) | |
| end | |
| Find.find(ARGV[0]) do |path| | |
| if path =~ /(.)+\.html$/ | |
| process(path) | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment