-
Notifications
You must be signed in to change notification settings - Fork 18k
go/doc: CLI go doc makes a mess of code blocks in interface method docs #43188
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
Comments
Thanks for filing! I will take a look. |
The issue is happening because struct methods return a So in the case of a interface method, a single line gets passed repeatedly to A full interface is also handled by @griesemer - Do you think we should handle this in the |
So the problem here is that comments in an interface are not attached to the Also, when I do |
No that's not entirely it. The comments are attached, but they are split into individual
Yep, that is because go/doc does not attach interface method to the doc.Type. And so trying to dig around the AST leads to different code paths. Maybe filtering the fields inside the full interface will lead to the unification of some code paths. I'll see what I can do. |
Change https://golang.org/cl/279433 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran
go doc
on an interface method with a code block, e.g.go doc context.Context.Done
.What did you expect to see?
I expected to see the relevant lines from the godoc, with the code block formatted reasonably:
What did you see instead?
Instead, go doc made a mess of the formatting:
This also happens for user-defined interfaces, of course. It does not happen if you ask for the whole interface's doc (
go doc context.Context
) or in a struct field (go doc http.Request.Header
) or method (go doc http.Request.Write
). The web view, and pkg.go.dev, display the whole interface doc, and don't run into this issue either.The text was updated successfully, but these errors were encountered: