OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // godoc: Go Documentation Server | 5 // godoc: Go Documentation Server |
6 | 6 |
7 // Web server tree: | 7 // Web server tree: |
8 // | 8 // |
9 // http://godoc/ main landing page | 9 // http://godoc/ main landing page |
10 // http://godoc/doc/ serve from $GOROOT/doc - spec, mem, tutorial, et
c. | 10 // http://godoc/doc/ serve from $GOROOT/doc - spec, mem, tutorial, et
c. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 path = pathutil.Join(cwd, path) | 234 path = pathutil.Join(cwd, path) |
235 } | 235 } |
236 relpath := path | 236 relpath := path |
237 abspath := path | 237 abspath := path |
238 if len(path) > 0 && path[0] != '/' { | 238 if len(path) > 0 && path[0] != '/' { |
239 abspath = absolutePath(path, pkgHandler.fsRoot) | 239 abspath = absolutePath(path, pkgHandler.fsRoot) |
240 } else { | 240 } else { |
241 relpath = relativePath(path) | 241 relpath = relativePath(path) |
242 } | 242 } |
243 | 243 |
244 » info := pkgHandler.getPageInfo(abspath, relpath, *genAST, true) | 244 » // TODO(gri): Provide a mechanism (flag?) to select a package |
| 245 » // if there are multiple packages in a directory. |
| 246 » info := pkgHandler.getPageInfo(abspath, relpath, "", *genAST, true) |
245 | 247 |
246 if info.PAst == nil && info.PDoc == nil && info.Dirs == nil { | 248 if info.PAst == nil && info.PDoc == nil && info.Dirs == nil { |
247 // try again, this time assume it's a command | 249 // try again, this time assume it's a command |
248 if len(path) > 0 && path[0] != '/' { | 250 if len(path) > 0 && path[0] != '/' { |
249 abspath = absolutePath(path, cmdHandler.fsRoot) | 251 abspath = absolutePath(path, cmdHandler.fsRoot) |
250 } | 252 } |
251 » » info = cmdHandler.getPageInfo(abspath, relpath, false, false) | 253 » » info = cmdHandler.getPageInfo(abspath, relpath, "", false, false
) |
252 } | 254 } |
253 | 255 |
254 if info.PDoc != nil && flag.NArg() > 1 { | 256 if info.PDoc != nil && flag.NArg() > 1 { |
255 args := flag.Args() | 257 args := flag.Args() |
256 info.PDoc.Filter(args[1:]) | 258 info.PDoc.Filter(args[1:]) |
257 } | 259 } |
258 | 260 |
259 if err := packageText.Execute(info, os.Stdout); err != nil { | 261 if err := packageText.Execute(info, os.Stdout); err != nil { |
260 log.Stderrf("packageText.Execute: %s", err) | 262 log.Stderrf("packageText.Execute: %s", err) |
261 } | 263 } |
262 } | 264 } |
OLD | NEW |