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"}}
-
+
+
+
+ Name |
+ Synopsis |
+
-
-
-
-
-
-
-

- {{end}}
-
-
+ {{if not ((eq $.Dirname "/src/cmd") $.DirFlat)}}
+
+ .. |
+
+ {{end}}
+
+ {{range .List}}
- Name |
- Synopsis |
-
-
- {{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}}
-
- {{html .Path}}
- |
- {{end}}
- {{else}}
-
- {{html .Name}}
- |
- {{end}}
-
- {{html .Synopsis}}
- |
- {{end}}
-
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+
+ {{html .Path}}
+ |
{{end}}
{{else}}
- {{range .List}}
-
- {{if $.DirFlat}}
- {{if .HasPkg}}
-
- {{html .Path}}
- |
- {{end}}
- {{else}}
-
- {{html .Name}}
- |
- {{end}}
-
- {{html .Synopsis}}
- |
-
- {{end}}
+
+ {{html .Name}}
+ |
{{end}}
-
-
- {{if eq $.Dirname "/src"}}
-
+
+ {{html .Synopsis}}
+ |
+
+ {{end}}
+
-
- {{if hasThirdParty .List }}
-
-
-
-
-
-
-
-
-
- Name |
- Synopsis |
-
-
- {{range .List}}
-
- {{if eq .FsRootType "GOPATH"}}
- {{if $.DirFlat}}
- {{if .HasPkg}}
-
- {{html .Path}}
- |
- {{end}}
- {{else}}
-
- {{html .Name}}
- |
- {{end}}
-
- {{html .Synopsis}}
- |
- {{end}}
-
- {{end}}
-
-
-
-
- {{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".
-
-
- - benchmarks — benchmarks to measure Go as it is developed.
- - blog — blog.golang.org's implementation.
- - build — build.golang.org's implementation.
- - crypto — additional cryptography packages.
- - debug — an experimental debugger for Go.
- - image — additional imaging packages.
- - mobile — experimental support for Go on mobile platforms.
- - net — additional networking packages.
- - perf — packages and tools for performance measurement, storage, and analysis.
- - review — a tool for working with Gerrit code reviews.
- - sync — additional concurrency primitives.
- - sys — packages for making system calls.
- - text — packages for working with text.
- - time — additional time packages.
- - tools — godoc, goimports, gorename, and other tools.
- - tour — tour.golang.org's implementation.
- - exp — experimental and deprecated packages (handle with care; may change without warning).
-
-
-
-
- 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}}
+
+
+
+
+
+
+
+
+

+
+
+
+ Name |
+ Synopsis |
+
+
+ {{range .List}}
+
+ {{if eq .FsRootType "GOROOT"}}
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+
+ {{html .Path}}
+ |
+ {{end}}
+ {{else}}
+
+ {{html .Name}}
+ |
+ {{end}}
+
+ {{html .Synopsis}}
+ |
+ {{end}}
+
+ {{end}}
+
+
+
+
+
+ {{if hasThirdParty .List }}
+
+
+
+
+
+
+
+
+
+ Name |
+ Synopsis |
+
+
+ {{range .List}}
+
+ {{if eq .FsRootType "GOPATH"}}
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+
+ {{html .Path}}
+ |
+ {{end}}
+ {{else}}
+
+ {{html .Name}}
+ |
+ {{end}}
+
+ {{html .Synopsis}}
+ |
+ {{end}}
+
+ {{end}}
+
+
+
+
+ {{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".
+
+
+ - benchmarks — benchmarks to measure Go as it is developed.
+ - blog — blog.golang.org's implementation.
+ - build — build.golang.org's implementation.
+ - crypto — additional cryptography packages.
+ - debug — an experimental debugger for Go.
+ - image — additional imaging packages.
+ - mobile — experimental support for Go on mobile platforms.
+ - net — additional networking packages.
+ - perf — packages and tools for performance measurement, storage, and analysis.
+ - review — a tool for working with Gerrit code reviews.
+ - sync — additional concurrency primitives.
+ - sys — packages for making system calls.
+ - text — packages for working with text.
+ - time — additional time packages.
+ - tools — godoc, goimports, gorename, and other tools.
+ - tour — tour.golang.org's implementation.
+ - exp — experimental and deprecated packages (handle with care; may change without warning).
+
+
+
+
+ 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"}}
+
+
+
+ Name |
+ Synopsis |
+
+
+ {{if not ((eq $.Dirname "/src/cmd") $.DirFlat)}}
+
+ .. |
+
+ {{end}}
+
+ {{range .List}}
+
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+
+ {{html .Path}}
+ |
+ {{end}}
+ {{else}}
+
+ {{html .Name}}
+ |
+ {{end}}
+
+ {{html .Synopsis}}
+ |
+
+ {{end}}
+
+
+{{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}}
-
-
-
-
-
-

- {{end}}
-
-
-
- Name |
- Synopsis |
-
-
- {{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}}
-
- {{html .Path}}
- |
- {{end}}
- {{else}}
-
- {{html .Name}}
- |
- {{end}}
-
- {{html .Synopsis}}
- |
- {{end}}
+ Name |
+ Synopsis |
- {{end}}
- {{else}}
- {{range .List}}
-
- {{if $.DirFlat}}
- {{if .HasPkg}}
-
- {{html .Path}}
- |
- {{end}}
- {{else}}
-
- {{html .Name}}
- |
- {{end}}
-
- {{html .Synopsis}}
- |
-
- {{end}}
- {{end}}
-
-
- {{if eq $.Dirname "/src"}}
-
-
- {{if hasThirdParty .List }}
-
-
-
-
-
-
-
-
-
- Name |
- Synopsis |
-
-
- {{range .List}}
-
- {{if eq .FsRootType "GOPATH"}}
+ {{range .List}}
+
+ {{if eq .FsRootType "GOROOT"}}
{{if $.DirFlat}}
{{if .HasPkg}}
@@ -1978,12 +1967,51 @@ function cgAddChild(tree, ul, cgn) {
{{html .Synopsis}}
|
{{end}}
-
- {{end}}
-
+
+ {{end}}
+
+
+
+
+
+ {{if hasThirdParty .List }}
+
-
+
+
+
+
+
+ Name |
+ Synopsis |
+
+
+ {{range .List}}
+
+ {{if eq .FsRootType "GOPATH"}}
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+
+ {{html .Path}}
+ |
+ {{end}}
+ {{else}}
+
+ {{html .Name}}
+ |
+ {{end}}
+
+ {{html .Synopsis}}
+ |
+ {{end}}
+
+ {{end}}
+
+
+
+
{{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}}
`,