From: Robert Griesemer
Date: Wed, 24 Mar 2010 23:28:59 +0000 (-0700)
Subject: godoc: show relative file names without leading '/' (per r's request)
X-Git-Tag: weekly.2010-03-30~66
X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=acfd6d5f055ca5283dff5de16390c1d0cfc9f0ca;p=gostls13.git
godoc: show relative file names without leading '/' (per r's request)
- change the various url-xxx formatters to return a relative URL path
- make the leading '/' for URLs explicit in the template
- on the way change some |html formatters to |html-esc
(html should only be used for formatting AST nodes)
R=rsc, r
CC=golang-dev
https://golang.org/cl/740041
---
diff --git a/lib/godoc/dirlist.html b/lib/godoc/dirlist.html
index a94f249d91..3c1e3aae01 100644
--- a/lib/godoc/dirlist.html
+++ b/lib/godoc/dirlist.html
@@ -18,9 +18,9 @@
{.repeated section @}
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index 60a5c38641..bde1b4868b 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -692,7 +692,8 @@ func urlFmt(w io.Writer, x interface{}, format string) {
// map path
relpath := relativePath(path)
- // convert to URL
+ // convert to relative URLs so that they can also
+ // be used as relative file names in .txt templates
switch format {
default:
// we should never reach here, but be resilient
@@ -705,13 +706,13 @@ func urlFmt(w io.Writer, x interface{}, format string) {
if strings.HasPrefix(relpath, "src/pkg/") {
relpath = relpath[len("src/pkg/"):]
}
- template.HTMLEscape(w, []byte(pkgHandler.pattern+relpath))
+ template.HTMLEscape(w, []byte(pkgHandler.pattern[1:]+relpath)) // remove trailing '/' for relative URL
case "url-src":
- template.HTMLEscape(w, []byte("/"+relpath))
+ template.HTMLEscape(w, []byte(relpath))
case "url-pos":
// line id's in html-printed source are of the
// form "L%d" where %d stands for the line number
- template.HTMLEscape(w, []byte("/"+relpath))
+ template.HTMLEscape(w, []byte(relpath))
fmt.Fprintf(w, "#L%d", line)
}
}