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

Comments

Projects
None yet
9 participants
@frewsxcv
Member

frewsxcv commented May 21, 2016

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

This comment has been minimized.

Member

frewsxcv commented May 22, 2016

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

This comment has been minimized.

Member

GuillaumeGomez commented May 22, 2016

I'll take a look.

@GuillaumeGomez

This comment has been minimized.

Member

GuillaumeGomez commented Jun 1, 2016

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 from Should generated documentation display implicit trait implementations? to Generated documentation should display implicit trait implementations Jun 14, 2016

@steveklabnik steveklabnik added T-rustdoc and removed A-docs labels Jun 27, 2016

@cbreeden

This comment has been minimized.

Contributor

cbreeden commented Sep 26, 2016

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

This comment has been minimized.

Member

frewsxcv commented Sep 26, 2016

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

This comment has been minimized.

HybridEidolon commented Sep 26, 2016

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

This comment has been minimized.

Member

frewsxcv commented Sep 26, 2016

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

@GuillaumeGomez

This comment has been minimized.

Member

GuillaumeGomez commented Sep 27, 2016

@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

This comment has been minimized.

Member

GuillaumeGomez commented Nov 6, 2016

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

@coder543

This comment has been minimized.

coder543 commented Jul 13, 2017

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

This comment has been minimized.

Member

steveklabnik commented Jul 13, 2017

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

This comment has been minimized.

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

This comment has been minimized.

coder543 commented Jul 13, 2017

@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.

@ehsanul

This comment has been minimized.

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

This comment has been minimized.

Member

GuillaumeGomez commented Jul 21, 2018

PR to fix it is now open.

bors added a commit that referenced this issue Jul 28, 2018

@bors bors closed this in #52585 Jul 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment