Skip to content

Commit 8e4f4c8

Browse files
committed
godoc: delete GoogleCN logic
The GoogleCN code is specific to the code for golang.org, which no longer uses golang.org/x/tools/godoc. For golang/go#32011. Change-Id: If13e3ed93d57f9d8a6c0f8a09b8343567dd6c0b1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/296373 Trust: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 44abc2a commit 8e4f4c8

File tree

8 files changed

+5
-83
lines changed

8 files changed

+5
-83
lines changed

godoc/godoc.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,8 @@ func sanitizeFunc(src string) string {
398398
}
399399

400400
type PageInfo struct {
401-
Dirname string // directory containing the package
402-
Err error // error or nil
403-
GoogleCN bool // page is being served from golang.google.cn
401+
Dirname string // directory containing the package
402+
Err error // error or nil
404403

405404
Mode PageInfoMode // display metadata from query string
406405

@@ -614,8 +613,7 @@ func (p *Presentation) example_htmlFunc(info *PageInfo, funcName string) string
614613

615614
err := p.ExampleHTML.Execute(&buf, struct {
616615
Name, Doc, Code, Play, Output string
617-
GoogleCN bool
618-
}{eg.Name, eg.Doc, code, play, out, info.GoogleCN})
616+
}{eg.Name, eg.Doc, code, play, out})
619617
if err != nil {
620618
log.Print(err)
621619
}

godoc/golangorgenv/golangorgenv.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

godoc/page.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import (
99
"os"
1010
"path/filepath"
1111
"runtime"
12-
"strings"
13-
14-
"golang.org/x/tools/godoc/golangorgenv"
1512
)
1613

1714
// Page describes the contents of the top-level godoc webpage.
@@ -22,7 +19,6 @@ type Page struct {
2219
SrcPath string
2320
Query string
2421
Body []byte
25-
GoogleCN bool // page is being served from golang.google.cn
2622
TreeView bool // page needs to contain treeview related js and css
2723

2824
// filled in by ServePage
@@ -57,26 +53,6 @@ func (p *Presentation) ServeError(w http.ResponseWriter, r *http.Request, relpat
5753
Title: "File " + relpath,
5854
Subtitle: relpath,
5955
Body: applyTemplate(p.ErrorHTML, "errorHTML", err),
60-
GoogleCN: googleCN(r),
6156
GoogleAnalytics: p.GoogleAnalytics,
6257
})
6358
}
64-
65-
// googleCN reports whether request r is considered
66-
// to be served from golang.google.cn.
67-
func googleCN(r *http.Request) bool {
68-
if r.FormValue("googlecn") != "" {
69-
return true
70-
}
71-
if strings.HasSuffix(r.Host, ".cn") {
72-
return true
73-
}
74-
if !golangorgenv.CheckCountry() {
75-
return false
76-
}
77-
switch r.Header.Get("X-Appengine-Country") {
78-
case "", "ZZ", "CN":
79-
return true
80-
}
81-
return false
82-
}

godoc/search.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func (p *Presentation) HandleSearch(w http.ResponseWriter, r *http.Request) {
122122
Tabtitle: query,
123123
Query: query,
124124
Body: body.Bytes(),
125-
GoogleCN: googleCN(r),
126125
})
127126
}
128127

godoc/server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
328328
info.TypeInfoIndex[ti.Name] = i
329329
}
330330

331-
info.GoogleCN = googleCN(r)
332331
var body []byte
333332
if info.Dirname == "/src" {
334333
body = applyTemplate(h.p.PackageRootHTML, "packageRootHTML", info)
@@ -340,7 +339,6 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
340339
Tabtitle: tabtitle,
341340
Subtitle: subtitle,
342341
Body: body,
343-
GoogleCN: info.GoogleCN,
344342
TreeView: hasTreeView,
345343
})
346344
}
@@ -610,7 +608,6 @@ func (p *Presentation) serveTextFile(w http.ResponseWriter, r *http.Request, abs
610608
SrcPath: relpath,
611609
Tabtitle: relpath,
612610
Body: buf.Bytes(),
613-
GoogleCN: googleCN(r),
614611
})
615612
}
616613

@@ -689,7 +686,6 @@ func (p *Presentation) serveDirectory(w http.ResponseWriter, r *http.Request, ab
689686
SrcPath: relpath,
690687
Tabtitle: relpath,
691688
Body: applyTemplate(p.DirlistHTML, "dirlistHTML", list),
692-
GoogleCN: googleCN(r),
693689
})
694690
}
695691

@@ -726,7 +722,6 @@ func (p *Presentation) ServeHTMLDoc(w http.ResponseWriter, r *http.Request, absp
726722
page := Page{
727723
Title: meta.Title,
728724
Subtitle: meta.Subtitle,
729-
GoogleCN: googleCN(r),
730725
}
731726

732727
// evaluate as template if indicated

godoc/static/example.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
<div class="buttons">
1414
<a class="run" title="Run this code [shift-enter]">Run</a>
1515
<a class="fmt" title="Format this code">Format</a>
16-
{{if not $.GoogleCN}}
1716
<a class="share" title="Share this code">Share</a>
18-
{{end}}
1917
</div>
2018
</div>
2119
{{else}}

godoc/static/godoc.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060
<div class="buttons">
6161
<a class="run" title="Run this code [shift-enter]">Run</a>
6262
<a class="fmt" title="Format this code">Format</a>
63-
{{if not $.GoogleCN}}
6463
<a class="share" title="Share this code">Share</a>
65-
{{end}}
6664
</div>
6765
</div>
6866
{{end}}

godoc/static/static.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)