diff --git a/cmd/godoc/handlers.go b/cmd/godoc/handlers.go index 6691ed72..137709bd 100644 --- a/cmd/godoc/handlers.go +++ b/cmd/godoc/handlers.go @@ -120,6 +120,7 @@ func readTemplates(p *godoc.Presentation, html bool) { p.ImplementsHTML = readTemplate("implements.html") p.MethodSetHTML = readTemplate("methodset.html") p.PackageHTML = readTemplate("package.html") + p.PackageRootHTML = readTemplate("packageroot.html") p.SearchHTML = readTemplate("search.html") p.SearchDocHTML = readTemplate("searchdoc.html") p.SearchCodeHTML = readTemplate("searchcode.html") diff --git a/godoc/pres.go b/godoc/pres.go index b8205e24..de23c756 100644 --- a/godoc/pres.go +++ b/godoc/pres.go @@ -33,6 +33,7 @@ type Presentation struct { ImplementsHTML, MethodSetHTML, PackageHTML, + PackageRootHTML, PackageText, SearchHTML, SearchDocHTML, diff --git a/godoc/server.go b/godoc/server.go index 2c564656..9240746d 100644 --- a/godoc/server.go +++ b/godoc/server.go @@ -321,11 +321,17 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } info.GoogleCN = googleCN(r) + var body []byte + if info.Dirname == "/src" { + body = applyTemplate(h.p.PackageRootHTML, "packageRootHTML", info) + } else { + body = applyTemplate(h.p.PackageHTML, "packageHTML", info) + } h.p.ServePage(w, Page{ Title: title, Tabtitle: tabtitle, Subtitle: subtitle, - Body: applyTemplate(h.p.PackageHTML, "packageHTML", info), + Body: body, GoogleCN: info.GoogleCN, }) } diff --git a/godoc/static/makestatic.go b/godoc/static/makestatic.go index 8ee8e556..aedc81a2 100644 --- a/godoc/static/makestatic.go +++ b/godoc/static/makestatic.go @@ -60,6 +60,7 @@ var files = []string{ "methodset.html", "opensearch.xml", "package.html", + "packageroot.html", "package.txt", "play.js", "playground.js", diff --git a/godoc/static/package.html b/godoc/static/package.html index c531cbd5..06f533ae 100644 --- a/godoc/static/package.html +++ b/godoc/static/package.html @@ -245,162 +245,37 @@ {{if $.PDoc}}

Subdirectories

{{end}} - {{if eq $.Dirname "/src"}} -
-
-
Standard library
- {{if hasThirdParty .List }} -
Third party
- {{end}} -
Other packages
-
Sub-repositories
-
Community
-
-
+
+ + + + + -
- -
-

Standard library ▾

- - {{end}} -
-
NameSynopsis
+ {{if not ((eq $.Dirname "/src/cmd") $.DirFlat)}} + + + + {{end}} + + {{range .List}} - - - - - {{if not (or (eq $.Dirname "/src") (eq $.Dirname "/src/cmd") $.DirFlat)}} - - - - {{end}} - - {{if eq $.Dirname "/src"}} - {{range .List}} - - {{if eq .FsRootType "GOROOT"}} - {{if $.DirFlat}} - {{if .HasPkg}} - - {{end}} - {{else}} - - {{end}} - - {{end}} - + {{if $.DirFlat}} + {{if .HasPkg}} + {{end}} {{else}} - {{range .List}} - - {{if $.DirFlat}} - {{if .HasPkg}} - - {{end}} - {{else}} - - {{end}} - - - {{end}} + {{end}} -
..
NameSynopsis
..
- {{html .Path}} - - {{html .Name}} - - {{html .Synopsis}} -
+ {{html .Path}} +
- {{html .Path}} - - {{html .Name}} - - {{html .Synopsis}} -
+ {{html .Name}} +
-
- {{if eq $.Dirname "/src"}} - + + {{html .Synopsis}} + + + {{end}} + - - {{if hasThirdParty .List }} -
- -
-

Third party ▾

-
- - - - - - - {{range .List}} - - {{if eq .FsRootType "GOPATH"}} - {{if $.DirFlat}} - {{if .HasPkg}} - - {{end}} - {{else}} - - {{end}} - - {{end}} - - {{end}} -
NameSynopsis
- {{html .Path}} - - {{html .Name}} - - {{html .Synopsis}} -
-
-
-
- {{end}} - -

Other packages

-

Sub-repositories

-

- These packages are part of the Go Project but outside the main Go tree. - They are developed under looser compatibility requirements than the Go core. - Install them with "go get". -

- - -

Community

-

- These services can help you find Open Source packages provided by the community. -

- - {{end}} {{end}} diff --git a/godoc/static/packageroot.html b/godoc/static/packageroot.html new file mode 100644 index 00000000..497f39a2 --- /dev/null +++ b/godoc/static/packageroot.html @@ -0,0 +1,150 @@ + + +{{with .PAst}} + {{range $filename, $ast := .}} + {{$filename|filename|html}}:
{{node_html $ $ast false}}
+ {{end}} +{{end}} + +{{with .Dirs}} + {{/* DirList entries are numbers and strings - no need for FSet */}} + {{if $.PDoc}} +

Subdirectories

+ {{end}} +
+
+
Standard library
+ {{if hasThirdParty .List }} +
Third party
+ {{end}} +
Other packages
+
Sub-repositories
+
Community
+
+
+ +
+ +
+

Standard library ▾

+ +
+ + + + + + + {{range .List}} + + {{if eq .FsRootType "GOROOT"}} + {{if $.DirFlat}} + {{if .HasPkg}} + + {{end}} + {{else}} + + {{end}} + + {{end}} + + {{end}} +
NameSynopsis
+ {{html .Path}} + + {{html .Name}} + + {{html .Synopsis}} +
+
+
+
+ + {{if hasThirdParty .List }} +
+ +
+

Third party ▾

+
+ + + + + + + {{range .List}} + + {{if eq .FsRootType "GOPATH"}} + {{if $.DirFlat}} + {{if .HasPkg}} + + {{end}} + {{else}} + + {{end}} + + {{end}} + + {{end}} +
NameSynopsis
+ {{html .Path}} + + {{html .Name}} + + {{html .Synopsis}} +
+
+
+
+ {{end}} + +

Other packages

+

Sub-repositories

+

+ These packages are part of the Go Project but outside the main Go tree. + They are developed under looser compatibility requirements than the Go core. + Install them with "go get". +

+ + +

Community

+

+ These services can help you find Open Source packages provided by the community. +

+ +{{end}} diff --git a/godoc/static/static.go b/godoc/static/static.go index 180660d1..ce43e24b 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -1865,12 +1865,69 @@ function cgAddChild(tree, ul, cgn) { {{if $.PDoc}}

Subdirectories

{{end}} - {{if eq $.Dirname "/src"}} +
+ + + + + + + {{if not ((eq $.Dirname "/src/cmd") $.DirFlat)}} + + + + {{end}} + + {{range .List}} + + {{if $.DirFlat}} + {{if .HasPkg}} + + {{end}} + {{else}} + + {{end}} + + + {{end}} +
NameSynopsis
..
+ {{html .Path}} + + {{html .Name}} + + {{html .Synopsis}} +
+
+{{end}} +`, + + "packageroot.html": ` + +{{with .PAst}} + {{range $filename, $ast := .}} + {{$filename|filename|html}}:
{{node_html $ $ast false}}
+ {{end}} +{{end}} + +{{with .Dirs}} + {{/* DirList entries are numbers and strings - no need for FSet */}} + {{if $.PDoc}} +

Subdirectories

+ {{end}}
Standard library
{{if hasThirdParty .List }} -
Third party
+
Third party
{{end}}
Other packages
Sub-repositories
@@ -1879,90 +1936,22 @@ function cgAddChild(tree, ul, cgn) {
- -
-

Standard library ▾

- - {{end}} -
- - - - - - - {{if not (or (eq $.Dirname "/src") (eq $.Dirname "/src/cmd") $.DirFlat)}} - - - - {{end}} - - {{if eq $.Dirname "/src"}} - {{range .List}} + +
+

Standard library ▾

+ +
+
NameSynopsis
..
- {{if eq .FsRootType "GOROOT"}} - {{if $.DirFlat}} - {{if .HasPkg}} - - {{end}} - {{else}} - - {{end}} - - {{end}} + + - {{end}} - {{else}} - {{range .List}} - - {{if $.DirFlat}} - {{if .HasPkg}} - - {{end}} - {{else}} - - {{end}} - - - {{end}} - {{end}} -
- {{html .Path}} - - {{html .Name}} - - {{html .Synopsis}} - NameSynopsis
- {{html .Path}} - - {{html .Name}} - - {{html .Synopsis}} -
-
- {{if eq $.Dirname "/src"}} -
-
- {{if hasThirdParty .List }} -
- -
-

Third party ▾

-
- - - - - - - {{range .List}} - - {{if eq .FsRootType "GOPATH"}} + {{range .List}} + + {{if eq .FsRootType "GOROOT"}} {{if $.DirFlat}} {{if .HasPkg}} {{end}} - - {{end}} -
NameSynopsis
@@ -1978,12 +1967,51 @@ function cgAddChild(tree, ul, cgn) { {{html .Synopsis}}
+ + {{end}} + +
+
+
+ + {{if hasThirdParty .List }} +
+ -
- +
+

Third party ▾

+
+ + + + + + + {{range .List}} + + {{if eq .FsRootType "GOPATH"}} + {{if $.DirFlat}} + {{if .HasPkg}} + + {{end}} + {{else}} + + {{end}} + + {{end}} + + {{end}} +
NameSynopsis
+ {{html .Path}} + + {{html .Name}} + + {{html .Synopsis}} +
+
+
+ {{end}}

Other packages

@@ -2022,7 +2050,6 @@ function cgAddChild(tree, ul, cgn) {
  • Go Search - a code search engine.
  • Projects at the Go Wiki - a curated list of Go projects.
  • - {{end}} {{end}} `,