Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Show methods from the whole Deref/DerefMut chain instead of only one level #71640

Closed
sdroege opened this issue Apr 28, 2020 · 5 comments · Fixed by #80653
Closed

rustdoc: Show methods from the whole Deref/DerefMut chain instead of only one level #71640

sdroege opened this issue Apr 28, 2020 · 5 comments · Fixed by #80653
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@sdroege
Copy link
Contributor

sdroege commented Apr 28, 2020

See for example https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer/message/struct.Message.html#deref-methods.

The type it derefs to also has another deref impl that would be useful to include here, see https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer/miniobject/struct.GstRc.html#impl-Deref .

In this case the expected result would be that the methods of both GstRc and MessageRef would be shown in the docs of Message.

CC @GuillaumeGomez @kinnison @rust-lang/rustdoc

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 28, 2020
@GuillaumeGomez
Copy link
Member

I think that all non-direct elements should be listed with no docs and just a link to their original items' page. Just adding a title before them to say that they come from the deref type.

What do you think?

@sdroege
Copy link
Contributor Author

sdroege commented Apr 28, 2020

Non-direct meaning that also e.g. the docs of Vec<T> wouldn't show the methods from &[T] anymore? IMHO it would make sense to show all levels. Can't become much longer than the docs of Vec<T> right now already :)

@sdroege sdroege changed the title rustdoc: Shows methods from the whole Deref/DerefMut chain instead of only one level rustdoc: Show methods from the whole Deref/DerefMut chain instead of only one level Apr 28, 2020
@jonas-schievink jonas-schievink added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Apr 28, 2020
@kinnison
Copy link
Contributor

One option would be to show the direct deref target as we do now, and pre-collapsed indirect deref targets all the way down.

@Nemo157
Copy link
Member

Nemo157 commented May 25, 2020

Dup of #53038 and #26207

@jyn514
Copy link
Member

jyn514 commented Jan 3, 2021

Duplicate of #26207.

@jyn514 jyn514 closed this as completed Jan 3, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2021
…GuillaumeGomez

Recursively document methods via `Deref` traits

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

Fixes rust-lang#26207
Fixes rust-lang#53038
Fixes rust-lang#71640

r? `@jyn514`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants