godoc: Fix commandline mode output.
Fix output of packages with multiple files.
Remove extra output when filter is requested.
Fixes golang/go#7115.

R=bradfitz, adg
CC=golang-codereviews
https://golang.org/cl/52750044
diff --git a/godoc/server.go b/godoc/server.go
index f152adc..3346730 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -97,7 +97,7 @@
 	if len(pkgfiles) > 0 {
 		// build package AST
 		fset := token.NewFileSet()
-		files, err := h.c.parseFiles(fset, abspath, pkgfiles)
+		files, err := h.c.parseFiles(fset, relpath, abspath, pkgfiles)
 		if err != nil {
 			info.Err = err
 			return info
@@ -128,7 +128,7 @@
 
 			// collect examples
 			testfiles := append(pkginfo.TestGoFiles, pkginfo.XTestGoFiles...)
-			files, err = h.c.parseFiles(fset, abspath, testfiles)
+			files, err = h.c.parseFiles(fset, relpath, abspath, testfiles)
 			if err != nil {
 				log.Println("parsing examples:", err)
 			}
@@ -156,7 +156,7 @@
 			if mode&NoFiltering == 0 {
 				packageExports(fset, pkg)
 			}
-			info.PAst = ast.MergePackageFiles(pkg, 0)
+			info.PAst = files
 		}
 		info.IsMain = pkgname == "main"
 	}
@@ -218,7 +218,10 @@
 	var tabtitle, title, subtitle string
 	switch {
 	case info.PAst != nil:
-		tabtitle = info.PAst.Name.Name
+		for _, ast := range info.PAst {
+			tabtitle = ast.Name.Name
+			break
+		}
 	case info.PDoc != nil:
 		tabtitle = info.PDoc.Name
 	default: