aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-03 11:25:20 -0800
committerRobert Griesemer <gri@golang.org>2009-12-03 11:25:20 -0800
commit6db683fe4d1e6f797b3cc6c1f7d1955c1c107826 (patch)
tree43f0c19ce2638b908dd77f41e0802a79ada6f6a1
parentc6e316a4b954cd2d6912cbfb0f5e00f0625862bd (diff)
downloadgo-6db683fe4d1e6f797b3cc6c1f7d1955c1c107826.tar.gz
go-6db683fe4d1e6f797b3cc6c1f7d1955c1c107826.zip
- include type-associated consts and vars when filtering a PackageDoc
- fixes a godoc issue (for instance, "godoc os EOF" now shows an entry) R=r CC=rsc https://golang.org/cl/165042
-rw-r--r--src/pkg/go/doc/doc.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pkg/go/doc/doc.go b/src/pkg/go/doc/doc.go
index 6b8cf87c82..b7cc8f3b0f 100644
--- a/src/pkg/go/doc/doc.go
+++ b/src/pkg/go/doc/doc.go
@@ -561,8 +561,8 @@ func isRegexp(s string) bool {
}
-func match(s string, a []string) bool {
- for _, t := range a {
+func match(s string, names []string) bool {
+ for _, t := range names {
if isRegexp(t) {
if matched, _ := regexp.MatchString(t, s); matched {
return true
@@ -622,16 +622,18 @@ func filterFuncDocs(a []*FuncDoc, names []string) []*FuncDoc {
func filterTypeDocs(a []*TypeDoc, names []string) []*TypeDoc {
w := 0;
for _, td := range a {
- match := false;
+ n := 0; // number of matches
if matchDecl(td.Decl, names) {
- match = true
+ n = 1
} else {
- // type name doesn't match, but we may have matching factories or methods
+ // type name doesn't match, but we may have matching consts, vars, factories or methods
+ td.Consts = filterValueDocs(td.Consts, names);
+ td.Vars = filterValueDocs(td.Vars, names);
td.Factories = filterFuncDocs(td.Factories, names);
td.Methods = filterFuncDocs(td.Methods, names);
- match = len(td.Factories) > 0 || len(td.Methods) > 0;
+ n += len(td.Consts) + len(td.Vars) + len(td.Factories) + len(td.Methods);
}
- if match {
+ if n > 0 {
a[w] = td;
w++;
}