Only document reachable APIs with cargo doc#16603
Only document reachable APIs with cargo doc#16603ojuschugh1 wants to merge 2 commits intorust-lang:masterfrom
cargo doc#16603Conversation
12fa44b to
e7d5853
Compare
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
tests/testsuite/doc_direct_deps.rs
Outdated
| pub_dep = { version = "0.0.1", public = true } | ||
| priv_dep = { version = "0.0.1", public = false } | ||
| priv_dep_with_dep = "0.0.1" | ||
| "#, |
There was a problem hiding this comment.
This is checking the mixed case for direct deps and not transitive deps. Is that intentional or did you meant for these to be indirect?
And what is it we are trying to get out of the mixed test vs other tests added?
There was a problem hiding this comment.
And what is it we are trying to get out of the mixed test vs other tests added?
Could you help me understand the role of this test?
There was a problem hiding this comment.
@ojuschugh1 there are outstanding questions on this
There was a problem hiding this comment.
Currently cargo doc generates docs for all transitive dependencies, which creates a lot of noise.
This allows library authors to control their documentation surface by
marking which dependencies are part of their public API.
The reason is that indirect private deps have no impact on the reader of the docs since they cannot be used and this can dramatically speed up documentation builds, especially with packages like windows-sys in a dependency tree
|
I have addressed your comments and feedback, kindly please review it and let me know @epage , after that i will make the commits proper. thanks |
|
@ojuschugh1 Would you mind cleaning up the commits to be atomic? (mentioned in the contributor guide) Atomic commits aren't just for Git history, they make it easier for reviewers to review changes. |
2fd32b8 to
d0ffd36
Compare
d0ffd36 to
a6cc3a8
Compare
a48ae5c to
31b786c
Compare
31b786c to
d327857
Compare
d327857 to
7e57124
Compare
|
Hi @epage , Gentle reminder could you kindly please reivew it, when you get a moment. Thanks |
7e57124 to
5d84a47
Compare
5d84a47 to
07b6c1b
Compare
| let should_doc_dep = if is_member || !public_deps_enabled { | ||
| true |
There was a problem hiding this comment.
Should this be is_member or is_root?
If I have
- workspace members
selectedandskipped selectedhas a private dependency onskipped- I run
cargo doc -p selected
Should we document the dependencies of skipped?
Either way, we should have a test for this.
There was a problem hiding this comment.
I think there is a hole in that example. We document dependencies by default, so the private status of skipped is irrelevant. Some layers might be needed to make the use case correct.
There was a problem hiding this comment.
Added a test doc_workspace_member_private_dep for this. Using is_member - workspace members get their deps documented regardless of how another member depends on them.
There was a problem hiding this comment.
But is that the behavior we want?
There was a problem hiding this comment.
I have renamed is_root to is_user_selected (backed by root_pkg_ids in State), which more precisely captures the intent: these are packages explicitly selected by the user (e.g. via -p), not just workspace members. The filter now only applies to deps of non-user-selected packages.
There was a problem hiding this comment.
root is the term we use through the compilation process.
There was a problem hiding this comment.
backed by root_pkg_ids in State
bcx has roots which is the Units that are a root
| } | ||
|
|
||
| #[cargo_test(nightly, reason = "public-dependency feature is unstable")] | ||
| fn doc_with_private_dependency() { |
There was a problem hiding this comment.
we should call out that this is a transitive private dependency
There was a problem hiding this comment.
Looks like this is still outstanding
fe28062 to
6e9b1f3
Compare
cargo doc
6e9b1f3 to
9ccbd9a
Compare
What does this PR try to resolve?
Fixes #2025
Adds support for documenting only direct dependencies when using the public-dependency feature. Currently cargo doc generates docs for all transitive dependencies, which creates a lot of noise. With this change, when
-Zpublic-dependencyis enabled, only direct deps and their public deps get documented.Backward compatible - without the flag everything works as before.