2

After updating the Android SDK and corresponding documentation on my Mac the search results for the locally stored documentation stopped linking to the correct locations. The search results link to root ("/") instead of the local documentation directory (ANDROID_SDK_DIRECTORY/docs/).

"Documentation for Android SDK" is for API version 16 and is revision 1.

4

3 回答 3

0

似乎搜索框只是将查询提供给 Google 的服务器,后者以https://developer.android.com上的 URL 进行回复。为了在本地 SDK 上搜索和打开页面,我使用了这个 shell 脚本:

#!/bin/sh

if [ -z $SDK_BASE ]; then
    SDK_BASE=/opt/android-sdk
fi

launched_new_window="false"

for f in `find $SDK_BASE/docs/ -iname \*$1\*.html`; do
    if [ $launched_new_window = "false" ]; then
        /usr/bin/chromium-browser --new-window $f
        launched_new_window=true
    else
        /usr/bin/chromium-browser $f
    fi
done
于 2014-01-10T02:55:43.573 回答
0

作为一种解决方法,我编辑了一个文档 Javascript 文件。编辑后的函数是文件 ANDROID_SDK_DIRECTORY/docs/assets/js/search_autocomplete.js 中的 search_changed(大约第 174 行)。在函数的开头添加了以下内容:

var cur_loc = window.location.pathname;
var slash_doc_slash = cur_loc.indexOf("/docs/");
if ( slash_doc_slash >= 0) {
    var after_bit = cur_loc.substr(slash_doc_slash + "/docs/".length);
    var after_bit_length = after_bit.length;
    var up_dots = "";
    for ( var i = 0; i < after_bit_length; i++) {
        var test_ch = after_bit.charAt(i);
        if ( test_ch == "/") {
            up_dots += "../";
        }
    }

    toroot = up_dots;
}
于 2012-07-10T10:28:20.060 回答
0

阅读 js 文件后ANDROID_SDK_DIRECTORY/docs/assets/js/search_autocomplete.js,在我看来搜索结果是由 google web search api 绘制的。如果我们想修改搜索结果,我们必须重写搜索引擎部分的代码。

于 2012-08-09T15:47:36.897 回答