-
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
x/tools/godoc,gddo: godoc associates Example functions that have suffixes rejected by cmd/vet and go/doc #43454
Comments
There is no |
Since you say this doesn't reproduce on |
Yes, sorry, x/tools/cmd/godoc. |
@julieqiu, are the |
Just to be clear, IMO the issue would be better fixed by relaxing the strictness of the vet check and testing docs, not the implementation of godoc. This does not look like the direction that is being taken. |
The suffix requirements are documented in the The inconsistency between Relaxing the behavior of those tools — along with other (unspecified, perhaps third-party) tools that currently rely on the documented requirements — seems like a much bigger task. That should probably go through the proposal process. |
This advice would have been helpful 2 years ago. The behaviour of example test annotation has been consistent since it was introduced, godoc has always accepted numeric prefixed tags, |
@bcmills re: #43454 (comment), @dmitshur is the current owner of x/tools/godoc. |
I believe pkgsite doesn't have 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?
~/src/gonum.org/v1/gonum/graph/topo$ go vet
gonum.org/v1/gonum/graph/topo_test
./2sat_example_test.go:177:1: ExampleTarjanSCC_2sat refers to unknown field or method: TarjanSCC.2sat
However, godoc renders the 2sat example.
What did you expect to see?
An error from vet and a failure from godoc to render the example or no error from vet and a godoc rendering of the example.
What did you see instead?
A vet error but a rendered example. See for example the godoc.org page here (note that pkg.go.dev does not render this example).
What would you like to see?
No error and a rendered example. That is, a relaxation of the documented requirement for an initial lowercase letter in the suffix ("The suffix must start with a lower-case letter.") to allow numeric leading glyphs.
Additional information
This is a repeat of #27442 which was closed into #23864 with comments there that this motivating issue would be considered in the fix. The change that that issue links to does not fix this problem consistently (local godoc does render the example, godoc.org also, but — in my view unreasonably stricly — pkg.go.dev does not). The documentation does say "The suffix must start with a lower-case letter." However given the rationale for that being a way of disambiguating methods' examples (which must start with an uppercase due to language rules) the requirement seems overly strict; it could be anything that is not a method, that is !uppercase as stated here.
/cc @dmitshur
The text was updated successfully, but these errors were encountered: