]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: don't lose exported consts/vars with unexported type
authorRobert Griesemer <gri@golang.org>
Mon, 13 Feb 2012 20:24:02 +0000 (12:24 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 13 Feb 2012 20:24:02 +0000 (12:24 -0800)
Fixes #2998.

R=rsc
CC=golang-dev
https://golang.org/cl/5650078

src/pkg/go/doc/reader.go
src/pkg/go/doc/testdata/b.0.golden
src/pkg/go/doc/testdata/b.1.golden
src/pkg/go/doc/testdata/b.2.golden
src/pkg/go/doc/testdata/b.go

index 13b465bbd78100c18a31d6215a21c0a47a2f7e68..5f0643caa3382df5671fcdeca2167284f6405ded 100644 (file)
@@ -274,7 +274,7 @@ func (r *reader) readValue(decl *ast.GenDecl) {
        // determine values list with which to associate the Value for this decl
        values := &r.values
        const threshold = 0.75
-       if domName != "" && domFreq >= int(float64(len(decl.Specs))*threshold) {
+       if domName != "" && r.isVisible(domName) && domFreq >= int(float64(len(decl.Specs))*threshold) {
                // typed entries are sufficiently frequent
                if typ := r.lookupType(domName); typ != nil {
                        values = &typ.values // associate with that type
index 7c33300616d2b87549e6c86a431c3d61a035a8ba..9d93392eaa59331c2943c8731df1802db6c9cde5 100644 (file)
@@ -11,19 +11,47 @@ FILENAMES
        testdata/b.go
 
 CONSTANTS
+       // 
+       const (
+               C1      notExported     = iota
+               C2
+       
+               C4
+               C5
+       )
+
+       // 
+       const C notExported = 0
+
        // 
        const Pi = 3.14 // Pi
 
 
 VARIABLES
+       // 
+       var (
+               U1, U2, U4, U5  notExported
+       
+               U7      notExported     = 7
+       )
+
        // 
        var MaxInt int  // MaxInt
 
+       // 
+       var V notExported
+
+       // 
+       var V1, V2, V4, V5 notExported
+
 
 FUNCTIONS
        // 
        func F(x int) int
 
+       // 
+       func F1() notExported
+
        // Always under the package functions list. 
        func NotAFactory() int
 
index f30380516bda5bed1153b662377afc5ca7b7a1e1..66c47b5c2a7175d853cd5f9293b3563a9d91eef7 100644 (file)
@@ -38,8 +38,42 @@ TYPES
        // 
        func (x *T) M()
 
+       // 
+       type notExported int
+
+       // 
+       const (
+               C1      notExported     = iota
+               C2
+               c3
+               C4
+               C5
+       )
+
+       // 
+       const C notExported = 0
+
+       // 
+       var (
+               U1, U2, u3, U4, U5      notExported
+               u6                      notExported
+               U7                      notExported     = 7
+       )
+
+       // 
+       var V notExported
+
+       // 
+       var V1, V2, v3, V4, V5 notExported
+
+       // 
+       func F1() notExported
+
+       // 
+       func f2() notExported
+
        // Should only appear if AllDecls is set. 
-       type uint struct{}
+       type uint struct{}      // overrides a predeclared type uint
 
        // Associated with uint type if AllDecls is set. 
        func UintFactory() uint
index 7c33300616d2b87549e6c86a431c3d61a035a8ba..9d93392eaa59331c2943c8731df1802db6c9cde5 100644 (file)
@@ -11,19 +11,47 @@ FILENAMES
        testdata/b.go
 
 CONSTANTS
+       // 
+       const (
+               C1      notExported     = iota
+               C2
+       
+               C4
+               C5
+       )
+
+       // 
+       const C notExported = 0
+
        // 
        const Pi = 3.14 // Pi
 
 
 VARIABLES
+       // 
+       var (
+               U1, U2, U4, U5  notExported
+       
+               U7      notExported     = 7
+       )
+
        // 
        var MaxInt int  // MaxInt
 
+       // 
+       var V notExported
+
+       // 
+       var V1, V2, V4, V5 notExported
+
 
 FUNCTIONS
        // 
        func F(x int) int
 
+       // 
+       func F1() notExported
+
        // Always under the package functions list. 
        func NotAFactory() int
 
index 28660f9be7c73ac095f6c532819b984e41ebe0f5..e50663b3dfaa8747cd13b173fd2baff61705db91 100644 (file)
@@ -6,6 +6,7 @@ package b
 
 import "a"
 
+// ----------------------------------------------------------------------------
 // Basic declarations
 
 const Pi = 3.14   // Pi
@@ -28,3 +29,30 @@ func uintFactory() uint {}
 
 // Should only appear if AllDecls is set.
 type uint struct{} // overrides a predeclared type uint
+
+// ----------------------------------------------------------------------------
+// Exported declarations associated with non-exported types must always be shown.
+
+type notExported int
+
+const C notExported = 0
+
+const (
+       C1 notExported = iota
+       C2
+       c3
+       C4
+       C5
+)
+
+var V notExported
+var V1, V2, v3, V4, V5 notExported
+
+var (
+       U1, U2, u3, U4, U5 notExported
+       u6                 notExported
+       U7                 notExported = 7
+)
+
+func F1() notExported {}
+func f2() notExported {}