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/cmd/godoc: ExampleABC functions not matching a suffix rule are not displayed #10494

Open
alandonovan opened this Issue Apr 17, 2015 · 1 comment

Comments

Projects
None yet
4 participants
@alandonovan
Contributor

alandonovan commented Apr 17, 2015

When viewing examples in godoc, a function called ExampleABC that doesn't match any of the suffix patterns described here

http://golang.org/pkg/testing/#hdr-Examples

is silently excluded. I would have expected it to be associated with the package.

The -ex flag makes no difference.

You can see an example in the x/tools repo, if you sync to 9c57c19a58835b00c0e3e283952087842242e49b and look at golang.org/x/tools/go/loader. The follow-up change, 41d9a0e7b2d60d52ef1caf232b081c16af220b44, renames the examples to make them visible.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 3, 2015

@rsc rsc modified the milestones: Unplanned, Go1.6 Jan 13, 2016

@agnivade

This comment has been minimized.

Member

agnivade commented Feb 4, 2018

This seems to be intended functionality -

name := stripExampleSuffix(e.Name)
if name == "" || globals[name] {
	examples = append(examples, e)
} else if c.Verbose {
	log.Printf("skipping example 'Example%s' because '%s' is not a known function or type", e.Name, e.Name)
}

https://github.com/golang/tools/blob/master/godoc/server.go#L434

It strips the suffix and checks whether it matches with a global name or not. Do we want to remove it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment