-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: go/doc: inline type alias documentation #44905
Comments
This would be useful for using ent. It uses a lot of code generation and includes aliases for several things in one of their own packages inside of the main generated package to make the usage easier, but the documentation winds up with things like
It's not particularly helpful, and getting the documentation for the aliased type can be a bit awkward because the generated package is also usually called
|
It's not clear this is a win always. Especially for aliases to non-internal packages.
you cannot change that to
because there is no U in p. Until now it has basically been the rule that if you need to do an alias to an internal type then you document everything in the package with the alias, because that's what users are looking at. |
This proposal has been added to the active column of the proposals project |
Maybe there should be a way to signal to godoc that you want it inlined?
This is not really a webui problem since pkgsite/godoc can link against For the cli, we already have the problem that We can also add a comment to clarify what is going on, similar to // T is exported.
//
// Alias: of internal.T.
type T struct { X U } Originally: Alternatives include partially qualifying the references: // T is exported.
type T struct { X internal.U } However this is confusing, imo, and propagates
This makes it really hard to see struct fields and implemented methods. |
@griesemer also points out that we do not even have dependency type information in 'go doc' today. We probably shouldn't make 'go doc' depend on doing that either, which would make it slower and potentially break sometimes. |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
I would like type aliases to be inlined for better readability. Consider a package with an extensive experimental API. Users would have to navigate back and forth between two (or more) packages: one containing the symbols they are allowed to access, and another one (or more) containing the usage documentation, struct fields, interface methods, etc. And where one experimental function accepts an experimental struct as a parameter:
When reading the documentation for
internal.MyInterface.MyFunc
, you seeMyStruct
. There is no back-reference toexperimental.MyStruct
. So you just have to hope the API designers are sane and didn't instead do:Originally posted by @dfawley in #34409 (comment)
The text was updated successfully, but these errors were encountered: