-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Removes references to hidden elementes in rustdoc #66715
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
impl<'a> DocFolder for ReferencesStripper<'a> { | ||
fn fold_item(&mut self, i: Item) -> Option<Item> { | ||
if let clean::ItemEnum::MethodItem(ref method) = &i.inner { | ||
if method.parent.map(|did| !self.retained.contains(&did)).unwrap_or(false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if method.parent.map(|did| !self.retained.contains(&did)).unwrap_or(false) { | |
if method.parent.map_or(false, |did| !self.retained.contains(&did)) { |
impl issue_13698::Foo for Foo {} | ||
// @!has - '//*[@id="method.foo2"]' 'fn foo2' | ||
impl issue_13698::FooAux for Foo { | ||
fn foo2(&self) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent of 2 instead of 4. ;)
impl Bar for Foo {} | ||
// @!has - '//*[@id="method.qux"]' 'fn qux' | ||
impl Bar for Foo { | ||
fn qux(&self) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent of 2 instead of 4. ;)
So far, code looks good to me (you even added tests!). However I wonder: if the child implementation of a trait wants to display a method implementation, how can it be done with this change? Currently, you have to re-use However, I'm open to other opinions on this topic. :) |
Oh, now I'm confused about the scope of the bug I'm supposed to be fixing 🙃 If I understood what you're saying, you are arguing that the current behavior is preferable since it is more flexible? I don't have a strong opinion, I assumed it was undesired because of the (repeated) chatter in #13698 about being unwanted/surprising. If that's the case, I guess this PR does not make much sense, and that in cases like #51147 (comment) what we want is to explicitly mark the implementations with |
Well, my point was that you can hide elements but you can't "unhide" them. ;) |
#13698 is a WONTFIX |
This is my first PR dealing with
rustc
/rustdoc
internals, usual warnings apply 😅This is a partial attempt to fix #13698. The approach is pretty blunt: we keep a reference to the defining item in a trait implementation, and we then strip all items with a "parent" marked as
#[doc(hidden)]
. It is not finished but I wanted to gather feedback early.TODOs / Questions / Doubts / Alternatives
Method
.Clean
implementation that I have modified is called during thecollect_trait_impls
pass. I'm not sure whether it would be better to try to tackle hidden elements at that point, instead of waiting tostrip-hidden
.parent
a good name for defining item? Maybedefinition
would be better?parent
field? Right now, I'm stuffing it into eachItemEnum
variant, but maybe we could just add it to theItem
struct.