Skip to content

Commit 050186b

Browse files
committed
cmd/golangorg: add golang.org/x/pkgsite repository
Allow golang.org/x repos to opt-in to use pkg.go.dev for documentation. The golang.org/x/pkgsite repository is the first one to use it. Update to current golang.org/x/build version and regenerate: go get golang.org/x/build/repos@92427f67eca1ac8f769c740f272196f368082630 go mod tidy go generate ./... Fixes golang/go#39150. For golang/go#36747. For golang/go#36106. Change-Id: Ia91725c12546c4e7467601d951144af3cb1e6863 Reviewed-on: https://go-review.googlesource.com/c/website/+/234678 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Julie Qiu <[email protected]>
1 parent 7fae553 commit 050186b

File tree

6 files changed

+236
-22
lines changed

6 files changed

+236
-22
lines changed

cmd/golangorg/x.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ func xHandler(w http.ResponseWriter, r *http.Request) {
4242
http.NotFound(w, r)
4343
return
4444
}
45+
docSite := "godoc.org"
46+
if repo.UsePkgGoDev() {
47+
docSite = "pkg.go.dev"
48+
}
4549
data := struct {
46-
Proj string // Gerrit project ("net", "sys", etc)
47-
Suffix string // optional "/path" for requests like /x/PROJ/path
48-
}{proj, suffix}
50+
DocSite string // Website providing documentation, either "godoc.org" or "pkg.go.dev".
51+
Proj string // Gerrit project ("net", "sys", etc)
52+
Suffix string // optional "/path" for requests like /x/PROJ/path
53+
}{docSite, proj, suffix}
4954
if err := xTemplate.Execute(w, data); err != nil {
5055
log.Println("xHandler:", err)
5156
}
@@ -57,10 +62,10 @@ var xTemplate = template.Must(template.New("x").Parse(`<!DOCTYPE html>
5762
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5863
<meta name="go-import" content="golang.org/x/{{.Proj}} git https://go.googlesource.com/{{.Proj}}">
5964
<meta name="go-source" content="golang.org/x/{{.Proj}} https://github.com/golang/{{.Proj}}/ https://github.com/golang/{{.Proj}}/tree/master{/dir} https://github.com/golang/{{.Proj}}/blob/master{/dir}/{file}#L{line}">
60-
<meta http-equiv="refresh" content="0; url=https://godoc.org/golang.org/x/{{.Proj}}{{.Suffix}}">
65+
<meta http-equiv="refresh" content="0; url=https://{{.DocSite}}/golang.org/x/{{.Proj}}{{.Suffix}}">
6166
</head>
6267
<body>
63-
Nothing to see here; <a href="https://godoc.org/golang.org/x/{{.Proj}}{{.Suffix}}">move along</a>.
68+
Nothing to see here; <a href="https://{{.DocSite}}/golang.org/x/{{.Proj}}{{.Suffix}}">move along</a>.
6469
</body>
6570
</html>
6671
`))

cmd/golangorg/x_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ func TestXHandler(t *testing.T) {
6060
substr(`http-equiv="refresh" content="0; url=https://godoc.org/golang.org/x/net/suffix">`),
6161
},
6262
},
63+
{
64+
name: "pkgsite",
65+
path: "/x/pkgsite",
66+
checks: []check{
67+
status(200),
68+
substr(`<meta name="go-import" content="golang.org/x/pkgsite git https://go.googlesource.com/pkgsite">`),
69+
substr(`Nothing to see here; <a href="https://pkg.go.dev/golang.org/x/pkgsite">move along</a>.`),
70+
substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/pkgsite">`),
71+
},
72+
},
6373
{
6474
name: "notexist",
6575
path: "/x/notexist",

content/static/packageroot.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ <h3 id="subrepo">Sub-repositories</h3>
128128
<li><a href="//godoc.org/golang.org/x/mobile">mobile</a> — experimental support for Go on mobile platforms.</li>
129129
<li><a href="//godoc.org/golang.org/x/net">net</a> — additional networking packages.</li>
130130
<li><a href="//godoc.org/golang.org/x/perf">perf</a> — packages and tools for performance measurement, storage, and analysis.</li>
131+
<li><a href="//pkg.go.dev/golang.org/x/pkgsite">pkgsite</a> — home of the pkg.go.dev website.</li>
131132
<li><a href="//godoc.org/golang.org/x/review">review</a> — a tool for working with Gerrit code reviews.</li>
132133
<li><a href="//godoc.org/golang.org/x/sync">sync</a> — additional concurrency primitives.</li>
133134
<li><a href="//godoc.org/golang.org/x/sys">sys</a> — packages for making system calls.</li>

content/static/static.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ module golang.org/x/website
33
go 1.11
44

55
require (
6-
cloud.google.com/go v0.38.0
6+
cloud.google.com/go/datastore v1.1.0
77
github.com/gomodule/redigo v2.0.0+incompatible
88
github.com/yuin/goldmark v1.1.22
9-
go.opencensus.io v0.22.0 // indirect
10-
golang.org/x/build v0.0.0-20191213161705-41fffb13b6ef
11-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
12-
golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0
13-
google.golang.org/api v0.9.0 // indirect
14-
google.golang.org/appengine v1.5.0
9+
golang.org/x/build v0.0.0-20200520141049-92427f67eca1
10+
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
11+
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb
12+
google.golang.org/appengine v1.6.5
1513
)

0 commit comments

Comments
 (0)