Command line tool for viewing documentation

Hi, new Rustacean here, so please bear with me :slight_smile: Is there an equivalent of "go doc" command line utility for Rust ? I had a look at the awesome-rust list too, but couldn't find a similar utility for Rust. Thanks in advance!

1 Like

Hi,

If you want to show documentation for a specific crate you do cargo doc --open and it will generate and show the documentation for you.

I'm not sure if that is what you are asking for or the general Rust documentation?

godoc prints documentation as plain text to stdout.

I'm not aware of any analogous tool in the Rust ecosystem.

1 Like

Hi @emoon, i checked "cargo doc --open". But as @BurntSushi said, i'm trying to view documentation about a specific Crate/Module/Function in the console screen. For instance:

go doc bufio

In the "Go land", the above command prints the documentation for functions/structs/interfaces in "bufio" package to standard output.

I'm still exploring the standard library and common crates. A similar utility for Rust would be very useful for newcomers like me. Thanks.

I see.

I use a third-party tool for that purpose Dash for macOS - API Documentation Browser, Snippet Manager - Kapeli that includes the Rust documentation (and many other langs/APIs) and I have a key combo in my editor to lookup something. This isn't likely exactly what you are looking for though.

1 Like

Thanks @emoon. I just came across this project on github:

oxidoc

Looks like it's in alpha state, but might be useful for console users in the future.

1 Like

Docs are generated from source code. You might want to jump to definition to read docs.

Sorry for necrobump. It's been a minute, but I still look for an equivalent of go doc every once in a while; I do most of my writing on neovim, which makes it somewhat clunkier to switch to a web browser for rust docs as opposed to e.g.

$ go doc flag.Parse
package flag // import "flag"

func Parse()
    Parse parses the command-line flags from os.Args[1:]. Must be called after
    all flags are defined and before flags are accessed by the program.

I also use and pay for Dash, but to be honest the below bookmark is what I use most:

file:///Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/share/doc/rust/html/std/index.html?search=%s

With this in Firefox, using the keyword rustdoc, I can rustdoc hashset (EDIT: from the FF address bar) and it pops up almost instantly to the appropriate search results, even offline.

Other alternatives:

$ rustup doc --std # opens the browser to basically the same file as above
$ rustup doc --std std::collections::HashSet # opens directly to the expected docs
$ rustup doc std::collections::HashSet # --std is default and can be omitted
$ rustup doc --std HashSet # wish it fell back to the search page, oh well
error: No document for 'HashSet'

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.