Skip to content

Commit

Permalink
Fix macro missing from doc search
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 16, 2018
1 parent a385095 commit afeb790
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/main.js
Expand Up @@ -160,6 +160,7 @@
// used for special search precedence
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
var TY_KEYWORD = itemTypes.indexOf("keyword");
var TY_MACRO = itemTypes.indexOf("macro");

onEach(document.getElementsByClassName('js-only'), function(e) {
removeClass(e, 'js-only');
Expand Down Expand Up @@ -465,9 +466,11 @@
var res = buildHrefAndPath(obj);
obj.displayPath = pathSplitter(res[0]);
obj.fullPath = obj.displayPath + obj.name;
// To be sure than it some items aren't considered as duplicate.
if (obj.ty === TY_KEYWORD) {
// To be sure than it isn't considered as duplicate with items.
obj.fullPath += '|k';
} else if (obj.ty === TY_MACRO) {
obj.fullPath += '|m';
}
obj.href = res[1];
out.push(obj);
Expand Down
20 changes: 20 additions & 0 deletions src/test/rustdoc-js/macro-check.js
@@ -0,0 +1,20 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-order

const QUERY = 'panic';

const EXPECTED = {
'others': [
{ 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros
{ 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules
],
};
2 changes: 1 addition & 1 deletion src/tools/rustdoc-js/tester.js
Expand Up @@ -233,7 +233,7 @@ function main(argv) {

var arraysToLoad = ["itemTypes"];
var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS",
"TY_PRIMITIVE", "TY_KEYWORD",
"TY_PRIMITIVE", "TY_KEYWORD", "TY_MACRO",
"levenshtein_row2"];
// execQuery first parameter is built in getQuery (which takes in the search input).
// execQuery last parameter is built in buildIndex.
Expand Down

0 comments on commit afeb790

Please sign in to comment.