Permalink
Browse files

Fixed sxdoc

  • Loading branch information...
fd committed Feb 22, 2013
1 parent e097bab commit 3c18d2be76d1398b84e84fbadccb7359801e02bf
@@ -17,12 +17,9 @@ import (
)
func serveError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
+ contents := applyTemplate(errorHTML, "errorHTML", err) // err may contain an absolute path!
w.WriteHeader(http.StatusNotFound)
- servePage(w, Page{
- Title: "File " + relpath,
- Subtitle: relpath,
- Body: applyTemplate(errorHTML, "errorHTML", err), // err may contain an absolute path!
- })
+ servePage(w, relpath, "File "+relpath, "", "", contents)
}
func init() {
@@ -37,7 +34,6 @@ func init() {
*indexFiles = indexFilenames
*maxResults = 100 // reduce latency by limiting the number of fulltext search results
*indexThrottle = 0.3 // in case *indexFiles is empty (and thus the indexer is run)
- *showPlayground = true
// read .zip file and set up file systems
const zipfile = zipFilename
@@ -52,7 +48,6 @@ func init() {
readTemplates()
initHandlers()
registerPublicHandlers(http.DefaultServeMux)
- registerPlaygroundHandlers(http.DefaultServeMux)
// initialize default directory tree with corresponding timestamp.
initFSTree()
View
@@ -68,11 +68,8 @@ func codewalk(w http.ResponseWriter, r *http.Request) {
return
}
- servePage(w, Page{
- Title: "Codewalk: " + cw.Title,
- Tabtitle: cw.Title,
- Body: applyTemplate(codewalkHTML, "codewalk", cw),
- })
+ b := applyTemplate(codewalkHTML, "codewalk", cw)
+ servePage(w, cw.Title, "Codewalk: "+cw.Title, "", "", b)
}
// A Codewalk represents a single codewalk read from an XML file.
@@ -202,10 +199,8 @@ func codewalkDir(w http.ResponseWriter, r *http.Request, relpath, abspath string
}
}
- servePage(w, Page{
- Title: "Codewalks",
- Body: applyTemplate(codewalkdirHTML, "codewalkdir", v),
- })
+ b := applyTemplate(codewalkdirHTML, "codewalkdir", v)
+ servePage(w, "", "Codewalks", "", "", b)
}
// codewalkFileprint serves requests with ?fileprint=f&lo=lo&hi=hi.
View
@@ -67,6 +67,8 @@ The flags are:
-maxresults=10000
maximum number of full text search results shown
(no full text index is built if maxresults <= 0)
+ -path=""
+ additional package directories (colon-separated)
-html
print HTML in command-line mode
-goroot=$GOROOT
@@ -86,8 +88,20 @@ The flags are:
zip file providing the file system to serve; disabled if empty
By default, godoc looks at the packages it finds via $GOROOT and $GOPATH (if set).
-This behavior can be altered by providing an alternative $GOROOT with the -goroot
-flag.
+Additional directories may be specified via the -path flag which accepts a list
+of colon-separated paths; unrooted paths are relative to the current working
+directory. Each path is considered as an additional root for packages in order
+of appearance. The last (absolute) path element is the prefix for the package
+path. For instance, given the flag value:
+
+ path=".:/home/bar:/public"
+
+for a godoc started in /home/user/godoc, absolute paths are mapped to package paths
+as follows:
+
+ /home/user/godoc/x -> godoc/x
+ /home/bar/x -> bar/x
+ /public/x -> public/x
When godoc runs as a web server and -index is set, a search index is maintained.
The index is created at startup.
View
@@ -54,8 +54,6 @@ type SegmentWriter func(w io.Writer, text []byte, selections int)
// Selection is ignored.
//
func FormatSelections(w io.Writer, text []byte, lw LinkWriter, links Selection, sw SegmentWriter, selections ...Selection) {
- // If we have a link writer, make the links
- // selection the last entry in selections
if lw != nil {
selections = append(selections, links)
}
@@ -110,8 +108,8 @@ func FormatSelections(w io.Writer, text []byte, lw LinkWriter, links Selection,
break
}
// determine the kind of segment change
- if lw != nil && index == len(selections)-1 {
- // we have a link segment change (see start of this function):
+ if index == len(selections)-1 {
+ // we have a link segment change:
// format the previous selection segment, write the
// link tag and start a new selection segment
segment(offs)
Oops, something went wrong.

0 comments on commit 3c18d2b

Please sign in to comment.