Skip to content

Commit

Permalink
优化脚本,修复部分路径替换错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
msdx committed Aug 19, 2015
1 parent 03aa98c commit 4e97932
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ <h5 class="jd-tagtitle">Throws</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">See Also</h5>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code></li>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code></li>
</ul>
</div>

Expand Down Expand Up @@ -2080,7 +2080,7 @@ <h5 class="jd-tagtitle">Throws</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">See Also</h5>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code></li>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code></li>
</ul>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ <h5 class="jd-tagtitle">Throws</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">See Also</h5>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code></li>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code></li>
</ul>
</div>

Expand Down Expand Up @@ -2408,7 +2408,7 @@ <h5 class="jd-tagtitle">Throws</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">See Also</h5>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code></li>
<ul class="nolist"><li><code><a href="ErrorDialogFragment.html">ErrorDialogFragment</a></code></li><li><code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code></li>
</ul>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3609,7 +3609,7 @@ <h5 class="jd-tagtitle">Parameters</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">Returns</h5>
<ul class="nolist"><li>The <code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code>.
<ul class="nolist"><li>The <code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code>.
</li></ul>
</div>

Expand Down Expand Up @@ -3657,7 +3657,7 @@ <h5 class="jd-tagtitle">Parameters</h5>
</div>
<div class="jd-tagdata">
<h5 class="jd-tagtitle">Returns</h5>
<ul class="nolist"><li>The <code><a href="Usage: ./pathtool -relative arg1 arg2">SupportErrorDialogFragment</a></code>.
<ul class="nolist"><li>The <code><a href="../../../../../default package/SupportErrorDialogFragment.html">SupportErrorDialogFragment</a></code>.
</li></ul>
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/com/google/android/gms/maps/MapView.html
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ <h2>Class Overview</h2>
A <code><a href="GoogleMap.html">GoogleMap</a></code> must be acquired using <code><a href="MapView.html#getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)">getMapAsync(OnMapReadyCallback)</a></code>.
The <code><a href="MapView.html">MapView</a></code> automatically initializes the maps system and the view.
<p>
For a simpler method of displaying a Map use <code><a href="MapFragment.html">MapFragment</a></code> (or <code><a href="Usage: ./pathtool -relative arg1 arg2">SupportMapFragment</a></code>)
For a simpler method of displaying a Map use <code><a href="MapFragment.html">MapFragment</a></code> (or <code><a href="../../../../../default package/SupportMapFragment.html">SupportMapFragment</a></code>)
if you are looking to target earlier platforms.
<p>
Note: You are advised not to add children to this view.
Expand Down
32 changes: 30 additions & 2 deletions handleabspath.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import groovy.io.FileType


def startTime = System.currentTimeMillis()
def pattern = ~/=\"\/[^\/].*?\.(?:html|jpg|png)/
def dir = new File("docs/")
def count = 0
Expand All @@ -11,7 +12,8 @@ dir.traverse(type: FileType.FILES, nameFilter: ~/.*\.html/) {
matcher.each { m ->
count++
def absPath = "docs" + (m - "=\"")
def relPath = "./pathtool -relative ${it.path} ${absPath}".execute().text.trim()
//def relPath = "./pathtool -relative ${it.path} ${absPath}".execute().text.trim()
def relPath = calcRelative(it.path, absPath)
// println it.path + ":" + absPath + ":" + relPath
fileText = fileText.replaceAll(m, "=\"" + relPath)
}
Expand All @@ -21,4 +23,30 @@ dir.traverse(type: FileType.FILES, nameFilter: ~/.*\.html/) {
fileCounts++
}
}
println "Files: ${fileCounts} Count:${count}"

def spendTime = (System.currentTimeMillis() - startTime) / 1000.0f
println "Files: ${fileCounts} Count:${count} Spend:${spendTime}s"

def calcRelative(String from, String to) {
String[] source = from.split("/");
String[] target = to.split("/"); // keep in mind that the arrays are of different length!
StringBuilder uniquePart = new StringBuilder();
StringBuilder relativePart = new StringBuilder();
boolean stillSame = true;
int sourceL = source.length - 1
int targetL = target.length - 1
for(int ii = 0; ii < source.length - 1 || ii < target.length; ii++) {
if(ii < targetL && ii < sourceL &&
stillSame && source[ii].equals(target[ii])) continue;
stillSame = false;
if(target.length > ii)
uniquePart.append("/").append(target[ii]);
if(source.length > ii +1)
relativePart.append("../");
}

if (uniquePart.charAt(0) == "/") {
uniquePart.deleteCharAt(0)
}
return relativePart.append(uniquePart.toString()).toString();
}

0 comments on commit 4e97932

Please sign in to comment.