Results for ' + escape(query.query) +
+
+ var ret_others = addTab(results['others'], query);
+ var ret_in_args = addTab(results['in_args'], query, false);
+ var ret_returned = addTab(results['returned'], query, false);
+
+ var output = 'Results for ' + escape(query.query) +
(query.type ? ' (type: ' + escape(query.type) + ')' : '') + '
' +
'
' +
- makeTabHeader(0, "In Names", results['others'].length) +
- makeTabHeader(1, "In Parameters", results['in_args'].length) +
- makeTabHeader(2, "In Return Types", results['returned'].length) +
- '
';
-
- output += addTab(results['others'], query);
- output += addTab(results['in_args'], query, false);
- output += addTab(results['returned'], query, false);
- output += '
';
+ makeTabHeader(0, "In Names", ret_others[1]) +
+ makeTabHeader(1, "In Parameters", ret_in_args[1]) +
+ makeTabHeader(2, "In Return Types", ret_returned[1]) +
+ '' +
+ ret_others[0] + ret_in_args[0] + ret_returned[0] + '
';
addClass(document.getElementById('main'), 'hidden');
var search = document.getElementById('search');
@@ -1347,12 +1370,13 @@
}
}
if (queries.length > 1) {
- function getSmallest(arrays, positions) {
+ function getSmallest(arrays, positions, notDuplicates) {
var start = null;
for (var it = 0; it < positions.length; ++it) {
if (arrays[it].length > positions[it] &&
- (start === null || start > arrays[it][positions[it]].lev)) {
+ (start === null || start > arrays[it][positions[it]].lev) &&
+ !notDuplicates[arrays[it][positions[it]].fullPath]) {
start = arrays[it][positions[it]].lev;
}
}
@@ -1362,19 +1386,23 @@
function mergeArrays(arrays) {
var ret = [];
var positions = [];
+ var notDuplicates = {};
for (var x = 0; x < arrays.length; ++x) {
positions.push(0);
}
while (ret.length < MAX_RESULTS) {
- var smallest = getSmallest(arrays, positions);
+ var smallest = getSmallest(arrays, positions, notDuplicates);
+
if (smallest === null) {
break;
}
for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
if (arrays[x].length > positions[x] &&
- arrays[x][positions[x]].lev === smallest) {
+ arrays[x][positions[x]].lev === smallest &&
+ !notDuplicates[arrays[x][positions[x]].fullPath]) {
ret.push(arrays[x][positions[x]]);
+ notDuplicates[arrays[x][positions[x]].fullPath] = true;
positions[x] += 1;
}
}
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index da4be7db5aa92..493a75e25211d 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -382,7 +382,7 @@ kbd {
}
#theme-choices > button:hover, #theme-choices > button:focus {
- background-color: #444;
+ background-color: #4e4e4e;
}
@media (max-width: 700px) {
@@ -397,3 +397,10 @@ kbd {
#all-types:hover {
background-color: #606060;
}
+
+.search-results td span.alias {
+ color: #fff;
+}
+.search-results td span.grey {
+ color: #ccc;
+}
\ No newline at end of file
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index 12af01d2e2498..22f4635fb02e1 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -390,4 +390,11 @@ kbd {
}
#all-types:hover {
background-color: #f9f9f9;
+}
+
+.search-results td span.alias {
+ color: #000;
+}
+.search-results td span.grey {
+ color: #999;
}
\ No newline at end of file
diff --git a/src/test/rustdoc-js/deduplication.js b/src/test/rustdoc-js/deduplication.js
new file mode 100644
index 0000000000000..0f29607d5c993
--- /dev/null
+++ b/src/test/rustdoc-js/deduplication.js
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-order
+
+const QUERY = 'is_nan';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'std::f32', 'name': 'is_nan' },
+ { 'path': 'std::f64', 'name': 'is_nan' },
+ { 'path': 'std::option::Option', 'name': 'is_none' },
+ ],
+};
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index 25f7a2d1294c5..47667d93cb7f1 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -160,10 +160,11 @@ function main(argv) {
// execQuery first parameter is built in getQuery (which takes in the search input).
// execQuery last parameter is built in buildIndex.
// buildIndex requires the hashmap from search-index.
- var functionsToLoad = ["levenshtein", "validateResult", "getQuery", "buildIndex", "execQuery",
- "execSearch"];
+ var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
+ "getQuery", "buildIndex", "execQuery", "execSearch"];
finalJS += 'window = { "currentCrate": "std" };\n';
+ finalJS += 'var rootPath = "../";\n';
finalJS += ALIASES;
finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);