-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: add go doc -json #34293
Comments
Hi @odeke-em , do you have any recommendation on where should I start looking if I am interested in this issue? |
@joshuabezaleel Note that this is a proposal. It may be accepted, but so far it has not been accepted. You are welcome to look into the issue, but if the proposal is not accepted your work will not be accepted either. Thanks. |
There is a go/doc package that lets you get package docs in Go data structures. It seems like that should be enough. Failing that, gopls clearly has some way to give docs to the editor for helper popups. What does it use? Also, more generally, gopls is the way to "better language support for editors and ide's". So if more is needed, it should be in gopls, not cmd/go or a URL on a web site. /cc @stamblerre |
LSP only supports plaintext or markdown for hover (see https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_hover), but |
@stamblerre, how does gopls get the docs in a data structure? Does it just use go/doc for that parsing? @paulvollmer, have you tried using go/doc? Is there anything missing from what it does? |
@rsc i'm using But maybe there is already a tool doing that. how are the html pages of golang.org/pkg generated? |
@rsc: |
go/doc already defines a data structure, doc.Package. @paulvollmer, if you got a doc.Package from go doc -json would that work for your use case? (We may need to create some parallel structures with the go/token and go/ast pieces properly converted, which we could do.) At the least that seems like a plausible path forward and is consistent with the other various -json flags in cmd/go. Thoughts? |
@rsc yes, i think this should provide the machine readable data i had in mind. let me know if i can help working on that task. |
Thanks for the response @paulvollmer. |
👍 I'll look inside the |
No change in consensus, so accepting. |
Hi @jayconrod , is this issue still open and a good one for beginners? Do you have any recommendation on where should I start looking if I am interested in this? |
Hi @joshuabezaleel - good to see you here. Please take a look at Russ' comment here as to what the implementation needs. It requires some knowledge of the go/doc and its sibling packages. We would want to dump the contents of doc.Package and whatever else is necessary to display the full information. |
Change https://golang.org/cl/334876 mentions this issue: |
good news: (from the cl, probably worth discussing here though)
|
I would be interested in this too. Our use case is to a auto-generate yaml / json openapi representation of a Go struct which consumes json in a rest api. I am particularly interested in using the comments of struct fields as description for the openapi property description. |
To build better language support for editors and ide's it could be helpful to have the docs as json.
For example
https://golang.org/pkg/strings.json
to get thestrings
package documentation.Or via terminal by a flag like
go doc fmt -format json
Then the docs can be used to generate snippets based on the documentation.
The text was updated successfully, but these errors were encountered: