Cargo: `cargo doc` only direct dependencies

Created on 5 Oct 2015  路  5Comments  路  Source: rust-lang/cargo

From #1529 I suggested the following

[...] but I'd like a way to have the docs generated for all of my direct dependencies, but not their dependencies. In fact I'd argue this should be the default behavior.

If I add a crate "bar" as a dependency of the crate I'm working on "foo", then I'd love to see both "foo" and "bar"s documentation. However, if "bar" needs "baz" I frankly couldn't care less, as that's the decision of "bar" and I shouldn't need to look up anything in "baz".

All this is to say, generate docs for dependencies in Cargo.toml, but not Cargo.lock.

Command-doc

Most helpful comment

This seems to hit the "Shared vs. Internal Dependencies" weakness pointed out in a wildcard dependencies RFC comment. Do you perhaps want to hide the crates that are just implementation details, no matter whose dependencies they are?

All 5 comments

This seems to hit the "Shared vs. Internal Dependencies" weakness pointed out in a wildcard dependencies RFC comment. Do you perhaps want to hide the crates that are just implementation details, no matter whose dependencies they are?

Yea that is even more ideal, in general is expect the docs generated to be "relevant" to a user of the crate. So internal crates can be ignored as well.

Maybe it would be even enough to just _hide_ external dependencies from the side bar to remove visual and cognitive clutter?

My expectation (as a relatively new rust/cargo user) when running cargo doc is that doc would only be built for the crates in my Cargo.toml.
More often than not, transitive dependencies are more stable and well understood.
However the choice to have transitive would be good as sometimes I do want to dive that deep.

Just for context...
I ended up here after looking for a way to navigate crate src in vscode.

Just a workaround, you could use third-party tools like cargo-makedocs (crates.io / GitHub).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ehuss picture ehuss  路  3Comments

fprijate picture fprijate  路  3Comments

tensorchen picture tensorchen  路  3Comments

alilleybrinker picture alilleybrinker  路  3Comments

rask picture rask  路  3Comments