Skip to content

Commit

Permalink
Auto merge of #50033 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - #49699 (Removed 'proc' from the reserved keywords list)
 - #49966 (Multiple query search)
 - #50013 (Remove no longer necessary comparison to Vec::splice.)
 - #50032 (rustdoc: Don't include private paths in all.html)

Failed merges:
  • Loading branch information
bors committed Apr 17, 2018
2 parents 881a7cd + 92d29c1 commit 9379bcd
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 158 deletions.
3 changes: 0 additions & 3 deletions src/liballoc/string.rs
Expand Up @@ -1521,9 +1521,6 @@ impl String {
/// and replaces it with the given string.
/// The given string doesn't need to be the same length as the range.
///
/// Note: Unlike [`Vec::splice`], the replacement happens eagerly, and this
/// method does not return the removed chars.
///
/// # Panics
///
/// Panics if the starting point or end point do not lie on a [`char`]
Expand Down
232 changes: 110 additions & 122 deletions src/librustdoc/html/layout.rs
Expand Up @@ -37,128 +37,116 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
-> io::Result<()>
{
write!(dst,
r##"<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="{description}">
<meta name="keywords" content="{keywords}">
<title>{title}</title>
<link rel="stylesheet" type="text/css" href="{root_path}normalize{suffix}.css">
<link rel="stylesheet" type="text/css" href="{root_path}rustdoc{suffix}.css"
id="mainThemeStyle">
{themes}
<link rel="stylesheet" type="text/css" href="{root_path}dark{suffix}.css">
<link rel="stylesheet" type="text/css" href="{root_path}light{suffix}.css" id="themeStyle">
<script src="{root_path}storage{suffix}.js"></script>
{css_extension}
{favicon}
{in_header}
</head>
<body class="rustdoc {css_class}">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
{before_content}
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
{logo}
{sidebar}
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="{root_path}brush{suffix}.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="{root_path}theme{suffix}.js"></script>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">{content}</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd>↑</kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd>↓</kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd>↹</kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
{after_content}
<script>
window.rootPath = "{root_path}";
window.currentCrate = "{krate}";
</script>
<script src="{root_path}main{suffix}.js"></script>
<script defer src="{root_path}search-index.js"></script>
</body>
</html>"##,
"<!DOCTYPE html>\
<html lang=\"en\">\
<head>\
<meta charset=\"utf-8\">\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\
<meta name=\"generator\" content=\"rustdoc\">\
<meta name=\"description\" content=\"{description}\">\
<meta name=\"keywords\" content=\"{keywords}\">\
<title>{title}</title>\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}normalize{suffix}.css\">\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}rustdoc{suffix}.css\" \
id=\"mainThemeStyle\">\
{themes}\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}dark{suffix}.css\">\
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}light{suffix}.css\" \
id=\"themeStyle\">\
<script src=\"{root_path}storage{suffix}.js\"></script>\
{css_extension}\
{favicon}\
{in_header}\
</head>\
<body class=\"rustdoc {css_class}\">\
<!--[if lte IE 8]>\
<div class=\"warning\">\
This old browser is unsupported and will most likely display funky \
things.\
</div>\
<![endif]-->\
{before_content}\
<nav class=\"sidebar\">\
<div class=\"sidebar-menu\">&#9776;</div>\
{logo}\
{sidebar}\
</nav>\
<div class=\"theme-picker\">\
<button id=\"theme-picker\" aria-label=\"Pick another theme!\">\
<img src=\"{root_path}brush{suffix}.svg\" width=\"18\" alt=\"Pick another theme!\">\
</button>\
<div id=\"theme-choices\"></div>\
</div>\
<script src=\"{root_path}theme{suffix}.js\"></script>\
<nav class=\"sub\">\
<form class=\"search-form js-only\">\
<div class=\"search-container\">\
<input class=\"search-input\" name=\"search\" \
autocomplete=\"off\" \
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
type=\"search\">\
</div>\
</form>\
</nav>\
<section id=\"main\" class=\"content\">{content}</section>\
<section id=\"search\" class=\"content hidden\"></section>\
<section class=\"footer\"></section>\
<aside id=\"help\" class=\"hidden\">\
<div>\
<h1 class=\"hidden\">Help</h1>\
<div class=\"shortcuts\">\
<h2>Keyboard Shortcuts</h2>\
<dl>\
<dt><kbd>?</kbd></dt>\
<dd>Show this help dialog</dd>\
<dt><kbd>S</kbd></dt>\
<dd>Focus the search field</dd>\
<dt><kbd>↑</kbd></dt>\
<dd>Move up in search results</dd>\
<dt><kbd>↓</kbd></dt>\
<dd>Move down in search results</dd>\
<dt><kbd>↹</kbd></dt>\
<dd>Switch tab</dd>\
<dt><kbd>&#9166;</kbd></dt>\
<dd>Go to active search result</dd>\
<dt><kbd>+</kbd></dt>\
<dd>Expand all sections</dd>\
<dt><kbd>-</kbd></dt>\
<dd>Collapse all sections</dd>\
</dl>\
</div>\
<div class=\"infos\">\
<h2>Search Tricks</h2>\
<p>\
Prefix searches with a type followed by a colon (e.g. \
<code>fn:</code>) to restrict the search to a given type.\
</p>\
<p>\
Accepted types are: <code>fn</code>, <code>mod</code>, \
<code>struct</code>, <code>enum</code>, \
<code>trait</code>, <code>type</code>, <code>macro</code>, \
and <code>const</code>.\
</p>\
<p>\
Search functions by type signature (e.g. \
<code>vec -> usize</code> or <code>* -> vec</code>)\
</p>\
<p>\
Search multiple things at once by splitting your query with comma (e.g. \
<code>str,u8</code> or <code>String,struct:Vec,test</code>)\
</p>\
</div>\
</div>\
</aside>\
{after_content}\
<script>\
window.rootPath = \"{root_path}\";\
window.currentCrate = \"{krate}\";\
</script>\
<script src=\"{root_path}main{suffix}.js\"></script>\
<script defer src=\"{root_path}search-index.js\"></script>\
</body>\
</html>",
css_extension = if css_file_extension {
format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}theme{suffix}.css\">",
root_path = page.root_path,
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/render.rs
Expand Up @@ -1728,7 +1728,9 @@ impl Context {
let mut dst = try_err!(File::create(&joint_dst), &joint_dst);
try_err!(dst.write_all(&buf), &joint_dst);

all.append(full_path(self, &item), &item_type);
if !self.render_redirect_pages {
all.append(full_path(self, &item), &item_type);
}
// Redirect from a sane URL using the namespace to Rustdoc's
// URL for the page.
let redir_name = format!("{}.{}.html", name, item_type.name_space());
Expand Down
77 changes: 70 additions & 7 deletions src/librustdoc/html/static/main.js
Expand Up @@ -1299,14 +1299,78 @@
printTab(currentTab);
}

function execSearch(query, searchWords) {
var queries = query.raw.split(",");
var results = {
'in_args': [],
'returned': [],
'others': [],
};

for (var i = 0; i < queries.length; ++i) {
var query = queries[i].trim();
if (query.length !== 0) {
var tmp = execQuery(getQuery(query), searchWords);

results['in_args'].push(tmp['in_args']);
results['returned'].push(tmp['returned']);
results['others'].push(tmp['others']);
}
}
if (queries.length > 1) {
function getSmallest(arrays, positions) {
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 = arrays[it][positions[it]].lev;
}
}
return start;
}

function mergeArrays(arrays) {
var ret = [];
var positions = [];

for (var x = 0; x < arrays.length; ++x) {
positions.push(0);
}
while (ret.length < MAX_RESULTS) {
var smallest = getSmallest(arrays, positions);
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) {
ret.push(arrays[x][positions[x]]);
positions[x] += 1;
}
}
}
return ret;
}

return {
'in_args': mergeArrays(results['in_args']),
'returned': mergeArrays(results['returned']),
'others': mergeArrays(results['others']),
};
} else {
return {
'in_args': results['in_args'][0],
'returned': results['returned'][0],
'others': results['others'][0],
};
}
}

function search(e) {
var query,
obj, i, len,
results = {"in_args": [], "returned": [], "others": []},
resultIndex;
var params = getQueryStringParams();
var query = getQuery(document.getElementsByClassName('search-input')[0].value);

query = getQuery(document.getElementsByClassName('search-input')[0].value);
if (e) {
e.preventDefault();
}
Expand All @@ -1328,8 +1392,7 @@
}
}

results = execQuery(query, index);
showResults(results);
showResults(execSearch(query, index));
}

function buildIndex(rawSearchIndex) {
Expand Down
27 changes: 13 additions & 14 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -336,24 +336,23 @@ declare_keywords! {
(46, Offsetof, "offsetof")
(47, Override, "override")
(48, Priv, "priv")
(49, Proc, "proc")
(50, Pure, "pure")
(51, Sizeof, "sizeof")
(52, Typeof, "typeof")
(53, Unsized, "unsized")
(54, Virtual, "virtual")
(55, Yield, "yield")
(49, Pure, "pure")
(50, Sizeof, "sizeof")
(51, Typeof, "typeof")
(52, Unsized, "unsized")
(53, Virtual, "virtual")
(54, Yield, "yield")

// Special lifetime names
(56, UnderscoreLifetime, "'_")
(57, StaticLifetime, "'static")
(55, UnderscoreLifetime, "'_")
(56, StaticLifetime, "'static")

// Weak keywords, have special meaning only in specific contexts.
(58, Auto, "auto")
(59, Catch, "catch")
(60, Default, "default")
(61, Dyn, "dyn")
(62, Union, "union")
(57, Auto, "auto")
(58, Catch, "catch")
(59, Default, "default")
(60, Dyn, "dyn")
(61, Union, "union")
}

// If an interner exists, return it. Otherwise, prepare a fresh one.
Expand Down

0 comments on commit 9379bcd

Please sign in to comment.