auto merge of #18528 : seanjensengrey/rust/doc-18498, r=brson
This addresses https://github.com/rust-lang/rust/issues/18498 by adding a prepopulated search box to do site search on `doc.rust-lang.org` using duckduckgo AND generating a search url against the rust documentation using the internal search facilities. * https://duckduckgo.com/?q=type+Option+unwrap_or_else+site%3Adoc.rust-lang.org * http://doc.rust-lang.org/core/?search=unwrap_or_else
This commit is contained in:
commit
bb70ee56db
1 changed files with 44 additions and 0 deletions
|
@ -11,9 +11,53 @@ Looks like you've taken a wrong turn.
|
||||||
|
|
||||||
Some things that might be helpful to you though:
|
Some things that might be helpful to you though:
|
||||||
|
|
||||||
|
## Search
|
||||||
|
* <form action="https://duckduckgo.com/">
|
||||||
|
<input type="text" id="site-search" name="q" size="80"></input>
|
||||||
|
<input type="submit" value="Search DuckDuckGo">
|
||||||
|
</form>
|
||||||
|
* Rust doc search: <span id="core-search"></span>
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
* [The Rust official site](http://rust-lang.org)
|
* [The Rust official site](http://rust-lang.org)
|
||||||
* [The Rust reference](http://doc.rust-lang.org/reference.html) (* [PDF](http://doc.rust-lang.org/reference.pdf))
|
* [The Rust reference](http://doc.rust-lang.org/reference.html) (* [PDF](http://doc.rust-lang.org/reference.pdf))
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
* [The standard library](http://doc.rust-lang.org/std/)
|
* [The standard library](http://doc.rust-lang.org/std/)
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function get_url_fragments() {
|
||||||
|
var last = document.URL.split("/").pop();
|
||||||
|
var tokens = last.split(".");
|
||||||
|
var op = [];
|
||||||
|
for (var i=0; i < tokens.length; i++) {
|
||||||
|
var t = tokens[i];
|
||||||
|
if (t == 'html' || t.indexOf("#") != -1) {
|
||||||
|
// no html or anchors
|
||||||
|
} else {
|
||||||
|
op.push(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_site_search() {
|
||||||
|
var op = get_url_fragments();
|
||||||
|
|
||||||
|
var search = document.getElementById('site-search');
|
||||||
|
search.value = op.join(' ') + " site:doc.rust-lang.org";
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_rust_search() {
|
||||||
|
var op = get_url_fragments();
|
||||||
|
var lt = op.pop();
|
||||||
|
|
||||||
|
// #18540, use a single token
|
||||||
|
|
||||||
|
var search = document.getElementById('core-search');
|
||||||
|
search.innerHTML = "<a href=\"http://doc.rust-lang.org/core/?search=" + lt + "\">" + lt + "</a>";
|
||||||
|
}
|
||||||
|
populate_site_search();
|
||||||
|
populate_rust_search();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue