godoc: be quiet by default about bad examples

Fixes golang/go#6759

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/26420044
This commit is contained in:
Brad Fitzpatrick 2013-11-14 09:01:08 -08:00
parent 75d66fbb7b
commit 88f792caef

View File

@ -131,7 +131,7 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode)
if err != nil {
log.Println("parsing examples:", err)
}
info.Examples = collectExamples(pkg, files)
info.Examples = collectExamples(h.c, pkg, files)
// collect any notes that we want to show
if info.PDoc.Notes != nil {
@ -320,7 +320,7 @@ func globalNames(pkg *ast.Package) map[string]bool {
}
// collectExamples collects examples for pkg from testfiles.
func collectExamples(pkg *ast.Package, testfiles map[string]*ast.File) []*doc.Example {
func collectExamples(c *Corpus, pkg *ast.Package, testfiles map[string]*ast.File) []*doc.Example {
var files []*ast.File
for _, f := range testfiles {
files = append(files, f)
@ -332,7 +332,7 @@ func collectExamples(pkg *ast.Package, testfiles map[string]*ast.File) []*doc.Ex
name := stripExampleSuffix(e.Name)
if name == "" || globals[name] {
examples = append(examples, e)
} else {
} else if c.Verbose {
log.Printf("skipping example 'Example%s' because '%s' is not a known function or type", e.Name, e.Name)
}
}