From 88f792caef10c2acb1770c614e6e7b272ceabbd1 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 14 Nov 2013 09:01:08 -0800 Subject: [PATCH] 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 --- godoc/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/godoc/server.go b/godoc/server.go index 95f4397936..dd3887a5fc 100644 --- a/godoc/server.go +++ b/godoc/server.go @@ -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) } }