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

Generated documentation should display implicit trait implementations #33772

Closed
frewsxcv opened this issue May 21, 2016 · 15 comments
Closed

Generated documentation should display implicit trait implementations #33772

frewsxcv opened this issue May 21, 2016 · 15 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@frewsxcv
Copy link
Member

use std::fmt;

struct A;

impl fmt::Display for A {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "A")
    }
}

In this example, I'm able to call let a = A; a.to_string() since A implements fmt::Display. The generated documentation doesn't mention anything about to_string. It'd be great if the documentation displayed all available methods for a given structure.

@frewsxcv
Copy link
Member Author

FYI, this implementation exists in case people were confused about the description above:

impl<T> ToString for T where T: Display + ?Sized

https://doc.rust-lang.org/std/string/trait.ToString.html

@GuillaumeGomez
Copy link
Member

I'll take a look.

@GuillaumeGomez
Copy link
Member

I've been looking for a few days and here are my current issues:

  • I don't know how I can get information on trait impls in sub crates.
  • I don't know how I can resolve the genericity "issue" (being able to know if a trait impl is also done on the type I'm looking for).

@frewsxcv frewsxcv changed the title Should generated documentation display implicit trait implementations? Generated documentation should display implicit trait implementations Jun 14, 2016
@steveklabnik steveklabnik added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs labels Jun 27, 2016
@GuillaumeGomez GuillaumeGomez added the E-help-wanted Call for participation: Help is requested to fix this issue. label Jul 3, 2016
@cbreeden
Copy link
Contributor

I have been working through the source code for method resolution (ie: how rustc resolves A.to_string() in this example) while working on reference documentation for the "dot" operator. See 36427.

I am under the impression that most of the logic found in the source for method resolution can translate to listing out implicit trait implementations. I'll take a look after I'm finsihed with the documentation, but if anyone else is curious to give it a stab, take a look at reference links found in 36427.

@frewsxcv
Copy link
Member Author

Awesome, thanks for sharing @cbreeden! I've been wanting to look into this issue, but I'm still reading through the librustdoc module. I haven't (yet) made any progress on this issue. Will update here if I do.

@HybridEidolon
Copy link

How would this information be shown for generic types? i.e. Thing<B> and impl<T: Debug> Debug for Thing<T> {} -- a separate section saying something like "When B is Debug..."?

@frewsxcv
Copy link
Member Author

@HybridEidolon Is there any reason you can think of why the shouldn't go in the already existing "Trait Implementations" section?

@GuillaumeGomez
Copy link
Member

@HybridEidolon: For the moment, "everyone" wants it. If your issue is just for the output wording, we can always resolve the type name before printing.

@GuillaumeGomez
Copy link
Member

I'll give a serious look into this to settle this matter once and for all.

@coder543
Copy link

This came up again today, just FYI.

From what I've heard, RLS has the potential to help a lot with generating documentation. Is this being actively worked on, or is it blocked on that?

@steveklabnik
Copy link
Member

Is this being actively worked on, or is it blocked on that?

Existing rustdoc is not being actively worked on. Well, @GuillaumeGomez is doing some things, but we're generally not tackling this kind of bug right now. The idea is that the new rustdoc will be fixing this kind of thing.

@theduke
Copy link
Contributor

theduke commented Jul 13, 2017

@steveklabnik first time I've heard about a new rustdoc.

Is there a discussion or tracking issue somewhere to read up on it? ( a quick search didn't help me find anything).

@coder543
Copy link

@theduke I've heard rumors floating around for awhile now that the new rustdoc will simply ask RLS for the documentation on each item in each crate, and maybe query RLS for some other things. This is because RLS will already know everything about all of the code, including docstrings, which traits a given type implements, etc.

@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 25, 2017
@ehsanul
Copy link
Contributor

ehsanul commented Jun 24, 2018

https://github.com/steveklabnik/doxidize

Edit: nvm, apparently that's a far future project.

The idea is that the new rustdoc will be fixing this kind of thing.

@steveklabnik This is no longer true, correct?

@GuillaumeGomez
Copy link
Member

PR to fix it is now open.

bors added a commit that referenced this issue Jul 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants