summaryrefslogtreecommitdiff
path: root/src/cmd/godoc/main.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-02-16 11:20:55 -0800
committerRobert Griesemer <gri@golang.org>2010-02-16 11:20:55 -0800
commiteaa18cf6078b210a8683fdf7c0533f1908f33d2b (patch)
tree696089ccc47c9bd9a84290641b86a6a72db76016 /src/cmd/godoc/main.go
parentf96c03e483aca8036176d436669ea99d25386e4a (diff)
downloadgolang-eaa18cf6078b210a8683fdf7c0533f1908f33d2b.tar.gz
godoc support for directories outside $GOROOT
Example use: godoc -path=/home/user1:/home/build/foo -http=:6666 will start a local godoc that maps urls starting with /pkg/user1 or /pkg/foo to the respective roots specified in the path. Missing: Handling of overlapping package directories, multiple packages per directory. R=rsc CC=golang-dev http://codereview.appspot.com/206078
Diffstat (limited to 'src/cmd/godoc/main.go')
-rw-r--r--src/cmd/godoc/main.go29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index f475d8fa1..ef08551ce 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -47,9 +47,6 @@ var (
// layout control
html = flag.Bool("html", false, "print HTML in command-line mode")
-
- // --- Hack to remember current directory
- workingDir string
)
@@ -112,7 +109,7 @@ func dosync(c *http.Conn, r *http.Request) {
// TODO(gri): The directory tree may be temporarily out-of-sync.
// Consider keeping separate time stamps so the web-
// page can indicate this discrepancy.
- fsTree.set(newDirectory(".", maxDirDepth))
+ fsTree.set(newDirectory(goroot, maxDirDepth))
fallthrough
case 1:
// sync failed because no files changed;
@@ -155,17 +152,7 @@ func main() {
log.Exitf("negative tabwidth %d", *tabwidth)
}
- // --- Start of hack.
- // Remember where we were, so "." works as a directory name.
- // Error's not worth worrying about; we just check for empty string
- // when we need it.
- workingDir, _ = os.Getwd()
- // --- End of hack.
-
- if err := os.Chdir(goroot); err != nil {
- log.Exitf("chdir %s: %v", goroot, err)
- }
-
+ initRoots()
readTemplates()
if *httpaddr != "" {
@@ -175,10 +162,14 @@ func main() {
log.Stderrf("Go Documentation Server\n")
log.Stderrf("address = %s\n", *httpaddr)
log.Stderrf("goroot = %s\n", goroot)
- log.Stderrf("cmdroot = %s\n", *cmdroot)
- log.Stderrf("pkgroot = %s\n", *pkgroot)
- log.Stderrf("tmplroot = %s\n", *tmplroot)
+ log.Stderrf("cmdroot = %s\n", cmdroot)
+ log.Stderrf("pkgroot = %s\n", pkgroot)
+ log.Stderrf("tmplroot = %s\n", tmplroot)
log.Stderrf("tabwidth = %d\n", *tabwidth)
+ if !fsMap.IsEmpty() {
+ log.Stderr("user-defined mapping:")
+ fsMap.Fprint(os.Stderr)
+ }
handler = loggingHandler(handler)
}
@@ -192,7 +183,7 @@ func main() {
// 1) set timestamp right away so that the indexer is kicked on
fsTree.set(nil)
// 2) compute initial directory tree in a goroutine so that launch is quick
- go func() { fsTree.set(newDirectory(".", maxDirDepth)) }()
+ go func() { fsTree.set(newDirectory(goroot, maxDirDepth)) }()
// Start sync goroutine, if enabled.
if *syncCmd != "" && *syncMin > 0 {