Documentation search engine (Chrome quick search)

Hi,

my current method to search through the Rust documentation (in Chrome) is:

  1. Ctrl + T (opening new tab)
  2. Typing “do” -> Chrome suggest “doc.rust-lang.org/std/” to me.
  • Pressing Enter
  • Waiting up to a second until JS is ready :frowning:
  • Press S and finally search

You see… step 4 sucks. I would like to use the fancy “new” chrome search… where I type “yo” to get “youtube.com”, press Tab to switch to the youtube search and can immediately search.

Are there any plans to make it happen?

Here’s a description of this behavior from the Chromium docs: http://www.chromium.org/tab-to-search

Implementing OpenSearch also would make it possible to add the docs as a search engine provider in Firefox.

2 Likes

... doesn't sound to difficult, does it? I don't know who is responsible for the documentation site... I would really appreciate this feature.

PRs welcome :wink:

https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/static/main.js

1 Like

There are some problems here:

  1. Chrome will just activate tab-to-search for sites visited without a path. So doc.rust-lang.org/std won’t work. And since every crate has it’s own search index, it doesn’t make sense to add the search to doc.rust-lang.org directly. Would it be possible to create a new sub domain like std.rust-lang.org? I guess that would be nice to have for some other reasons too.
  2. The opensearch specification seems just to allow absolute URLs (including the server!). Rustdoc is just creates static html files… That would be a problem. Chrome has no problem with relative path’s though… Haven’t tested for Firefox.
  3. The actual search is performed locally via JS. So it still takes a few hundred ms on my machine to load and render the page and finally preparing and executing the search with JS. Again: A consequence of static html files and I understand that generating static html is not bad. Nevertheless: Maybe there is a better way to do that… we could add an option to rustdoc to specify a non local search provider… Something like that. Would be great for the official documentation at least. The search-index.js for the official documentation is 1MB already…

I know that you all have probably more important things to do right now, but still: Any ideas/comments?

You can right click the search field and “Add a keyword for this search” (Firefox) or “Add as search engine” (Chrome). I’ve set the keyword to rs, so I can type e.g. rs iterator, <enter> to quickly get to the search results page.

Even though the search happens client side, the URLs are of the form http://doc.rust-lang.org/std/?search=foo as if the server handled the search. The returned HTML is the same, and you’ll see the main page briefly appear before the JS parses the query string and runs the search.

1 Like

I didn’t knew the “keyword” feature of Chrome, thanks for that. But I think most users don’t know about it and don’t want to manually set the search engine.

Sure, there is a query URL for that. I still don’t like the “brief” moment before the search results appear. But as already said: Not really possible with static HTML.

Since this is real low priority, I will just look if I can add a small “button” that will trigger a JS function trying to add the search provider to the browser. I think this should be possible somehow.

Hi, I think my extension is what you need. :blush:

https://internals.rust-lang.org/t/a-handy-browser-extension-to-search-crates-and-official-docs-in-address-bar-omnibox/

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.