rust icon indicating copy to clipboard operation
rust copied to clipboard

Rustdoc should consider not hiding items that come from the same Cargo workspace

Open Urgau opened this issue 9 months ago • 1 comments

With PR https://github.com/rust-lang/rust/pull/124939, rustdoc hides in the "Aliased type" section of type alias every type that is not from the current crate.

However if we had access in rustdoc to the Cargo workspace information we could instead be more fine-grain and not hide those coming from the same workspace.

Crate A:

pub struct One<T>(T);

Crate B:

pub type OneString = One<String>;

If crate A and B are in the same workspace we should probably not hide the inner item, and therefor display:

// in Aliased Type
struct OneString(String)

// instead of
struct OneString(/* private items */)

@rustbot labels +T-rustdoc +A-rustdoc-ui +C-discussion

Urgau avatar May 11 '24 11:05 Urgau

Rather than rustdoc gaining workspace knowledge, another approach would be for cargo to pass a flag when building the in-workspace rmetas saying that they should have private details exposed. Then rustdoc could see this from the metadata when it's generating docs involving an external type. That leaves the policy of when to expose private details up to the build system, and you could imagine something like a --document-all-private-items flag for cargo that applies it to all dependencies, or applying it to non-workspace path dependencies as well.

Nemo157 avatar May 13 '24 20:05 Nemo157