godoc: support for multiple packages in a directory

- smartly select the "right" package
- provide a list of other packages

R=rsc
CC=golang-dev
https://golang.org/cl/466042
This commit is contained in:
Robert Griesemer 2010-03-12 18:16:21 -08:00
parent 1a5cd2c0e1
commit 226c2ec256
4 changed files with 80 additions and 27 deletions

View file

@ -241,14 +241,16 @@ func main() {
relpath = relativePath(path)
}
info := pkgHandler.getPageInfo(abspath, relpath, *genAST, true)
// TODO(gri): Provide a mechanism (flag?) to select a package
// if there are multiple packages in a directory.
info := pkgHandler.getPageInfo(abspath, relpath, "", *genAST, true)
if info.PAst == nil && info.PDoc == nil && info.Dirs == nil {
// try again, this time assume it's a command
if len(path) > 0 && path[0] != '/' {
abspath = absolutePath(path, cmdHandler.fsRoot)
}
info = cmdHandler.getPageInfo(abspath, relpath, false, false)
info = cmdHandler.getPageInfo(abspath, relpath, "", false, false)
}
if info.PDoc != nil && flag.NArg() > 1 {