godoc: fix source links for cmd/*
Fixes golang/go#12159 Change-Id: Id498443171cbdf0fe9808745a79edc863d836db1 Reviewed-on: https://go-review.googlesource.com/14001 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
1330b289ad
commit
31971b7521
|
@ -266,6 +266,18 @@ func testWeb(t *testing.T, withIndex bool) {
|
|||
},
|
||||
needIndex: true,
|
||||
},
|
||||
{
|
||||
path: "/pkg/strings/",
|
||||
match: []string{
|
||||
`href="/src/strings/strings.go"`,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/cmd/compile/internal/amd64/",
|
||||
match: []string{
|
||||
`href="/src/cmd/compile/internal/amd64/reg.go"`,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if test.needIndex && !withIndex {
|
||||
|
|
|
@ -119,12 +119,13 @@ func NewPresentation(c *Corpus) *Presentation {
|
|||
p: p,
|
||||
c: c,
|
||||
pattern: "/cmd/",
|
||||
fsRoot: "/src/cmd",
|
||||
fsRoot: "/src",
|
||||
}
|
||||
p.pkgHandler = handlerServer{
|
||||
p: p,
|
||||
c: c,
|
||||
pattern: "/pkg/",
|
||||
stripPrefix: "pkg/",
|
||||
fsRoot: "/src",
|
||||
exclude: []string{"/src/cmd"},
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ type handlerServer struct {
|
|||
p *Presentation
|
||||
c *Corpus // copy of p.Corpus
|
||||
pattern string // url pattern; e.g. "/pkg/"
|
||||
stripPrefix string // prefix to strip from import path; e.g. "pkg/"
|
||||
fsRoot string // file system root to which the pattern is mapped; e.g. "/src"
|
||||
exclude []string // file system paths to exclude; e.g. "/src/cmd"
|
||||
}
|
||||
|
@ -235,7 +236,7 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
relpath := pathpkg.Clean(r.URL.Path[len(h.pattern):])
|
||||
relpath := pathpkg.Clean(r.URL.Path[len(h.stripPrefix)+1:])
|
||||
abspath := pathpkg.Join(h.fsRoot, relpath)
|
||||
mode := h.p.GetPageInfoMode(r)
|
||||
if relpath == builtinPkgPath {
|
||||
|
|
Loading…
Reference in New Issue