From ae3dd780638c91310484a648d2b9f51c6e4bba57 Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Fri, 15 Nov 2013 11:03:25 -0800 Subject: [PATCH] godoc: Index const and vars in godoc. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/26990043 --- godoc/index.go | 2 +- godoc/index_test.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/godoc/index.go b/godoc/index.go index 7371876e..f7f45ea6 100644 --- a/godoc/index.go +++ b/godoc/index.go @@ -430,7 +430,7 @@ func (x *Indexer) visitIdent(kind SpotKind, id *ast.Ident) { name := x.intern(id.Name) switch kind { - case TypeDecl, FuncDecl: + case TypeDecl, FuncDecl, ConstDecl, VarDecl: x.curPkgExports[name] = kind } diff --git a/godoc/index_test.go b/godoc/index_test.go index c505e28f..66a1ba54 100644 --- a/godoc/index_test.go +++ b/godoc/index_test.go @@ -20,6 +20,10 @@ package foo import "bar" +const Pi = 3.1415 + +var Foos []Foo + // Foo is stuff. type Foo struct{} @@ -87,7 +91,7 @@ func TestIndexWriteRead(t *testing.T) { } func testIndex(t *testing.T, ix *Index) { - wantStats := Statistics{Bytes: 256, Files: 3, Lines: 16, Words: 6, Spots: 9} + wantStats := Statistics{Bytes: 291, Files: 3, Lines: 20, Words: 8, Spots: 12} if !reflect.DeepEqual(ix.Stats(), wantStats) { t.Errorf("Stats = %#v; want %#v", ix.Stats(), wantStats) } @@ -116,8 +120,10 @@ func testIndex(t *testing.T, ix *Index) { if got, want := ix.Exports(), map[string]map[string]SpotKind{ "foo": map[string]SpotKind{ - "Foo": TypeDecl, - "New": FuncDecl, + "Pi": ConstDecl, + "Foos": VarDecl, + "Foo": TypeDecl, + "New": FuncDecl, }, "other/bar": map[string]SpotKind{ "X": FuncDecl,