[Solved] Mouseless docs.rs

Is there a way to use docs.rs without the mice?

In particular, I'm looking for a set of hot keys for:

  1. search for crate
  2. search for function/struct/enum within crate
  3. moving up/dolwn the search results
  4. jumping around

On one hand, the UI seems to be built where lots of keyboard shortcuts are possible, but I can't seem to find a "cohesive" set of keybindings to eliminate the mice entirely.

If you're just scripting a task, and have access to the browser, then tab and enter are all you should really need, although not really hotkeys.

1 Like

I'm not automating anything yet (though perhaps I should).

This is purely for human/manual navigation.

What I don't like about tab/shift-tab is that it's linear in the number of clickable things, so it's pretty slow to move around (compared to mice).

I was thinking more along the lines of Emac's https://github.com/emacs-helm/helm or https://github.com/abo-abo/avy

which easily lets me jump to the function/struct/enum I care about.

1 Like

There's a few longstanding bugs in docs.rs related to keyboard accessibility.

https://github.com/rust-lang/docs.rs/issues/67

2 Likes

I think here's an interesting thought experiment: given a list of package/function-struct-enum names, what UI would allow one to jump to the definition in the least number of keystrokes.

Tab/Shift-tab would probably not be part of that UI.

docs.rs shows promise, but I'm not sure if it can be used as such a UI.

Ideally, the UI would be something like:

  1. I start typing part of crate name
  2. There's an auto completion of possible crate names
  3. There's a way to select a crate name

===

  1. Now, I start typing a function/struct/enum name
  2. There's an auto completion of possible crate names
  3. There's a way to select a function/struct/enum

Hmm, if your bug from 2.5 years ago isn't fixed, it's unlikely the keyboard shortcuts I want will be supported anytime soon.

Suggestions for docs.rs alternatives?

Local rustdoc (accessible using cargo doc --open) actually has pretty good keyboard support. If you press ?, it gives you a list of existing keyboard shortcuts, which includes one to jump to the search bar. It's just the docs.rs-specific stuff that has the major bugs.

3 Likes

cargo doc --open is very cool. Thanks!

I generally use Tridactyl (in Firefox, Vimium in Chrome) to browse any web site with the keyboard. Docs.rs works well with those.

3 Likes