# Pre-RFC: cargo doc --no-indirect-deps

**URL:** https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316
**Category:** cargo
**Created:** [August 5, 2024, 6:35pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316 "2024-08-05T18:35:35Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![binarycat](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/binarycat/32/12210_2.png) [@binarycat](https://internals.rust-lang.org/u/binarycat)
#### Post date: [August 5, 2024, 6:35pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/1 "2024-08-05T18:35:35Z")

</div>

this would only document direct dependancies found in `Cargo.toml`, as well as the crate itself

## Alternatives

1. add an optional argument to `--no-deps`, eg. `--no-deps=indirect`.
2. add a different option like `--document-deps` that allows more fine tuned control (possible options: `always`, `never`, `direct`)
3. add an option for explicitly listing all the crates to document.

## Future Possibilities

option to also document deps that have items referenced in the public api of direct deps, either through function argument/return types, or through re-exports.

---

<div class="post-metadata">

### Author: ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)
#### Post date: [August 5, 2024, 7:50pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/2 "2024-08-05T19:50:51Z")

</div>

I think we should wait on designing this until we have public/private dependencies. I wonder if we could even make this the default behavior at that point.

---

<div class="post-metadata">

### Author: ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)
#### Post date: [August 6, 2024, 2:51am UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/3 "2024-08-06T02:51:47Z")

</div>

For crates which set `#![doc(html_root_url)]` and thus still have their types link to their documentation, I actually still prefer letting them do so instead of having the extra doc clutter (at least while I have an internet connection), and keep the local docs for just the local crates. I'm thoroughly used to navigating to the correct crate's docs before searching.

Although, in fairness, since I use a shared `$CARGO_TARGET_DIR` for all my workspaces, my docs clutter builds up a bit more than a typical config and wouldn't actually be limited to just trans-public dependencies of the workspace, since it includes all crates documented since my last `cargo clean`.

---

<div class="post-metadata">

### Author: ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)
#### Post date: [August 6, 2024, 3:12pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/4 "2024-08-06T15:12:13Z")

</div>

> [@CAD97](#):
>
> For crates which set `#![doc(html_root_url)]` and thus still have their types link to their documentation, I actually still prefer letting them do so instead of having the extra doc clutter (at least while I have an internet connection), and keep the local docs for just the local crates. I'm thoroughly used to navigating to the correct crate's docs before searching.

I think there is some context I'm missing as I'm not understandin how my proposed idea (`cargo doc` only includes direct deps and their public dependencies) impacts this

---

<div class="post-metadata">

### Author: ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)
#### Post date: [August 6, 2024, 4:15pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/5 "2024-08-06T16:15:01Z")

</div>

> [@epage](#):
>
> I think there is some context I'm missing

Specifically, I tend to prefer using the online docs over local docs. When a type from a dependency is visible in the crate's API, it links to the local doc copy if available, or the online one at the specified `#![doc(html_root_url)]` otherwise.

Or maybe it was changed to default to using the docsrs root when unspecified, it's been a while since I've deliberately paid attention to that. I just recall a while ago that the attribute was required, thus why a decent number of notable crates use that attribute and have release checklists/scripts to keep the version number in it synced.

docsrs has its own setup to fixup intercrate links, and I'm trying to use cargo-docsrs locally more to keep a closer docs build environment.

---

<div class="post-metadata">

### Author: ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)
#### Post date: [August 6, 2024, 6:52pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/6 "2024-08-06T18:52:44Z")

</div>

How is that related to changing `cargo doc` from "build all dependencies" to "build all reachable dependencies"?

---

<div class="post-metadata">

### Author: ![DragonDev1906](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@DragonDev1906](https://internals.rust-lang.org/u/DragonDev1906)
#### Post date: [August 7, 2024, 3:50pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/7 "2024-08-07T15:50:47Z")

</div>

> [@CAD97](#):
>
> Specifically, I tend to prefer using the online docs over local docs.

Same for me: I find it faster to type `docs.rs/<crate-name>` in the browser than having a local `cargo doc` running or remembering to open a previously created one, especially when you know what crate something belongs to.

Personally I probably wouldn't use it, since I tend to know which dependency I want something from, so I'm usually using the all or nothing approach, especially since you often have to know something from re-exports or indirect dependencies to find out why something doesn't work. From that perspective it often doesn't matter much if it's a direct or indirect dependency (making an indirect dependency a direct one because you need something from it directly can be useful). But I can see how it could be useful during development.

> [@epage](#):
>
> until we have public/private dependencies

That sounds interesting, do you have a link or rfc for that?

---

<div class="post-metadata">

### Author: ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)
#### Post date: [August 7, 2024, 4:02pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/8 "2024-08-07T16:02:51Z")

</div>

> [@DragonDev1906](#):
>
> That sounds interesting, do you have a link or rfc for that?

> <https://github.com/rust-lang/rust/issues/44663>
>
> This is the tracking issue for ~~rust-lang/rfcs#1977~~ rust-lang/rfcs#3516 - pub…lic and private dependencies in cargo.
> 
> See also rust-lang/cargo#6129 for tracking on the Cargo side.
> 
> \### Unresolved Questions
> 
> \### Steps
> 
> \- \[\] Implementation
> - \[x\] rust-lang/rust#57586
> - \[x\] rust-lang/rust#59335
> - \[x\] #67074 
> - \[\] #71043
> - \[\] #119428
> - \[\] https://github.com/rust-lang/rust/pull/122665
> - \[x\] https://github.com/rust-lang/rust/pull/122757
> - \[x\] rust-lang/cargo#6653
> - \[x\] rust-lang/cargo#6772
> - \[x\] rust-lang/cargo#6962
> - \[x\] rust-lang/cargo#12817
> - \[x\] rust-lang/cargo#13039
> - \[x\] rust-lang/cargo#13036
> - \[x\] rust-lang/cargo#13037
> - \[\] rust-lang/cargo#13038
> - \[x\] rust-lang/cargo#13308
> - \[\] ~~Command to update Cargo.lock to minimal versions (rust-lang/cargo#4100)~~
> - \[\] ~~Make \`cargo publish\` use the minimal versions allowed by Cargo.toml~~
> - \[\] Ensure quality of error messages is sufficient
> - \[\] rust-lang/cargo#13095
> - \[\] Make \`exported-private-dependencies\` \`allow\`-by-default pre-2024 and \`deny\`-by-default in 2024+ / in the 2024-compatibility lint group
> - \[\] Perform a crater run and evaluate whether the pre-202x edition lint should be \`allow\` or \`warn\` (\[context from zulip\](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/RFC.20.233516.20-.20RFC.3A.20Superseding.20public.2Fprivate.20dependencies/near/419166799))
> \- \[\] Implement migration lints.
> \- \[\] Add documentation to the \[edition guide\]\[\].
> \- \[\] Ensure ready for Rust 2024 stabilization.
> 
> \[dev guide\]: https://github.com/rust-lang/rustc-dev-guide
> \[doc-guide\]: https://rustc-dev-guide.rust-lang.org/stabilization\_guide.html#documentation-prs
> \[edition guide\]: https://github.com/rust-lang/edition-guide
> \[nightly style procedure\]: https://github.com/rust-lang/style-team/blob/master/nightly-style-procedure.md
> \[reference\]: https://github.com/rust-lang/reference
> \[reference-instructions\]: https://github.com/rust-lang/reference/blob/master/CONTRIBUTING.md
> \[style guide\]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide
> 
> Non-blocking further improvements
> \- rust-lang/cargo#13096
> 
> \### Changes from RFC
> 
> \- RFC did not specify workspace inheritance behavior. With rust-lang/cargo#13125, we disallow it.
> 
> cc @rust-lang/cargo @epage

---

<div class="post-metadata">

### Author: ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)
#### Post date: [January 29, 2026, 4:03pm UTC](https://internals.rust-lang.org/t/pre-rfc-cargo-doc-no-indirect-deps/21316/9 "2026-01-29T16:03:28Z")

</div>

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