View own crate documentation

I know I can view lots of Rust documentation, including API documentation for the standard library, in my default browser by entering rustup doc.
And I know I can generate documentation for the crate of the current project by entering cargo doc.
I can view that documentation by browsing target/doc/{crate-name}.
Is there a command that opens that documentation in the default browser?
Can I navigate to that in the browser window opened by the rustup doc command?

cargo doc --open

2 Likes

And cargo doc --no-deps --open if you want to avoid building documentation for all your dependencies.

I also like cargo-makedocs for building documentation for my crate and only its direct dependencies.

4 Likes

I like to generate docs for non-public types, modules and functions in my code. Makes searching more relevant.

cargo doc --document-private-items
3 Likes