Skip to content

Methods from anonymous types obscure godoc's output #2791

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

Closed
niemeyer opened this issue Jan 26, 2012 · 8 comments
Closed

Methods from anonymous types obscure godoc's output #2791

niemeyer opened this issue Jan 26, 2012 · 8 comments
Milestone

Comments

@niemeyer
Copy link
Contributor

We've recently added support for showing the methods of anonymous fields in godoc as
part of their outer type, but it seems that showing that information by default may
easily get more confusing than helpful when one of the underlying types has more than a
few methods:

   http://goneat.org/lp/lpad

It's a significant growth in the perception of the API surface, and the methods that
come from the anonymous field are not as relevant as the methods on the type itself, so
it's obscured considerably the interesting interface for each of the types.
@rsc
Copy link
Contributor

rsc commented Jan 26, 2012

Comment 1:

This does appear to be redundant: the embedded field
is an exported one, so it is already visible in the documentation.
I believe we should only be showing these additional
methods if they are reachable via _unexported_ fields,
in the same way that we don't show methods for embeddings
of exported types from other package.s

Labels changed: added priority-go1, removed priority-triage.

Status changed to Accepted.

@niemeyer
Copy link
Contributor Author

Comment 2:

As a related detail, the embedded fields that come from anonymous types are lying about
whether the receiver is a pointer or not:
    http://tip.goneat.org/pkg/archive/zip/#Writer.Write

@niemeyer
Copy link
Contributor Author

Comment 3:

Erm, s/embedded fields/methods/

@rsc
Copy link
Contributor

rsc commented Jan 27, 2012

Comment 4:

Actually, the documentation is correct.  The value zip.Writer
implements Write, because the value contains an embedded
*countWriter, and the receiver for countWriter's Write method
needs a pointer.
Russ

@niemeyer
Copy link
Contributor Author

Comment 5:

Ah, I hadn't looked from that perspective. I guess it's just slightly confusing. When I
looked at the documentation, it surprised me that (w Writer) was the receiver. It felt
like a bug in the code.

@rsc
Copy link
Contributor

rsc commented Jan 27, 2012

Comment 6:

It may well be a bug in the code, one that we haven't noticed
because there was no direct visiblity into the exact method sets.
I noticed the same thing about your embedded *Value in the
example you sent in.  In many ways this is working as intended,
but I agree that it is too cluttered to keep as is.

@rsc
Copy link
Contributor

rsc commented Jan 30, 2012

Comment 7:

Labels changed: added go1-must.

@griesemer
Copy link
Contributor

Comment 8:

This issue was closed by revision 3c6bebf.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants