mirror of https://github.com/golang/go.git
go/doc: don't lose exported consts/vars with unexported type
Fixes #2998. R=rsc CC=golang-dev https://golang.org/cl/5650078
This commit is contained in:
parent
47424d90ec
commit
0a2ffb2638
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue