summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-02-19 11:41:48 -0800
committerRobert Griesemer <gri@golang.org>2010-02-19 11:41:48 -0800
commit9c9748492d080a2e3f3c78686a2d8bf65f45ceb7 (patch)
tree126a8cccfed54852707dc06948ae0527fb8c0a52
parent8e09ecd8512466092fd1c0dbfff31edf0ad4fd83 (diff)
downloadgolang-9c9748492d080a2e3f3c78686a2d8bf65f45ceb7.tar.gz
godoc: make commandline use work again
R=rsc CC=golang-dev http://codereview.appspot.com/216054
-rw-r--r--src/cmd/godoc/godoc.go13
-rw-r--r--src/cmd/godoc/main.go4
2 files changed, 7 insertions, 10 deletions
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index 08a990296..98cac945f 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -1100,14 +1100,12 @@ type httpHandler struct {
}
-// getPageInfo returns the PageInfo for a package directory path. If
+// getPageInfo returns the PageInfo for a package directory dirname. If
// the parameter try is true, no errors are logged if getPageInfo fails.
// If there is no corresponding package in the directory, PageInfo.PDoc
// is nil. If there are no subdirectories, PageInfo.Dirs is nil.
//
-func (h *httpHandler) getPageInfo(relpath string, try bool) PageInfo {
- dirname := absolutePath(relpath, h.fsRoot)
-
+func (h *httpHandler) getPageInfo(dirname, relpath string, try bool) PageInfo {
// filter function to select the desired .go files
filter := func(d *os.Dir) bool {
// If we are looking at cmd documentation, only accept
@@ -1129,9 +1127,7 @@ func (h *httpHandler) getPageInfo(relpath string, try bool) PageInfo {
// Get the best matching package: either the first one, or the
// first one whose package name matches the directory name.
- // The package name is the directory name within its parent
- // (use dirname instead of path because dirname is clean; i.e.
- // has no trailing '/').
+ // The package name is the directory name within its parent.
_, pkgname := pathutil.Split(dirname)
var pkg *ast.Package
for _, p := range pkgs {
@@ -1177,7 +1173,8 @@ func (h *httpHandler) ServeHTTP(c *http.Conn, r *http.Request) {
}
relpath := r.URL.Path[len(h.pattern):]
- info := h.getPageInfo(relpath, false)
+ abspath := absolutePath(relpath, h.fsRoot)
+ info := h.getPageInfo(abspath, relpath, false)
if r.FormValue("f") == "text" {
contents := applyTemplate(packageText, "packageText", info)
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index 0074a22de..5ce7f9d51 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -224,11 +224,11 @@ func main() {
packageText = packageHTML
}
- info := pkgHandler.getPageInfo(flag.Arg(0), true)
+ info := pkgHandler.getPageInfo(flag.Arg(0), flag.Arg(0), true)
if info.PDoc == nil && info.Dirs == nil {
// try again, this time assume it's a command
- info = cmdHandler.getPageInfo(flag.Arg(0), false)
+ info = cmdHandler.getPageInfo(flag.Arg(0), flag.Arg(0), false)
}
if info.PDoc != nil && flag.NArg() > 1 {