-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/go/analysis: pkgsite documentation for golang.org/x/tools/go/analysis/passes/* often lacks details #58950
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
I agree that doc.go makes sense. See https://go.dev/cl/474935 for a sketch of a starting point.
|
Change https://go.dev/cl/474935 mentions this issue: |
I wonder if that ExtractDoc function is something that could go in maybe the standard library |
Thanks @adonovan https://go.dev/cl/474935's approach is
(+) One copy and place where the document is I was originally thinking a different approach
(+) No magic keyword or convention in the package documentation. |
I think the benefit of having a single copy (that is automatically readable in pkgsite) probably offsets the risk of markup (e.g. cross-refs) being accidentally included in the plain text version. Perhaps we can apply the go/doc/comment parser and format such things, so we get the best of both worlds: HTML in the browser and plain text in the terminal? I agree we need to support multiple analyzers. Perhaps we should require a section called |
This CL defines an internal function, ExtractDoc, which extracts documentation from the analyzer's package doc. This allows a single doc comment to serve as both the package doc comment (which is served by sites such as pkg.go.dev) and the analyzer documentation (which is accessible through the command-line tool), appropriately formatted for both media. Also, change all our analyzers with nontrivial documentation to use it. The chosen syntax permits a single doc comment to document multiple analyzers and looks good in the pkgsite HTML rendering and the go vet help output. The HTML heading anchors are predictable. For now this is internal, but we might want to publish it. (After a proposal.) Updates golang/go#58950 See golang/go#57906 Change-Id: Ifc0f48e54c3e42bc598649a7139e178a1a653c13 Reviewed-on: https://go-review.googlesource.com/c/tools/+/474935 Run-TryBot: Alan Donovan <adonovan@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Looks good at master: https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness@master Closing this as the work is done, and x/tools will automatically be released at some point. |
I am not sure if this is a feature request for pkgsite, or it's just because the go analysis analyzer code was structured in a way not friendly with go documentation. Analyzers often place the helpful details in Doc constant, but this long doc is hidden from documentation
https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness
Would be nice if the documentation page of analyzers presents sufficient details.
The pattern I saw in similar situation was to generate the package doc (doc.go) from the types but not sure if that's the best way.
cc @adonovan @golang/tools-team
The text was updated successfully, but these errors were encountered: