Commit 03109350 authored by Robert Griesemer's avatar Robert Griesemer

godoc: show all top-level decls for (fake) package builtin

R=r, adg
CC=golang-dev
https://golang.org/cl/4904045
parent e6ae13d3
...@@ -767,6 +767,10 @@ func serveFile(w http.ResponseWriter, r *http.Request) { ...@@ -767,6 +767,10 @@ func serveFile(w http.ResponseWriter, r *http.Request) {
const fakePkgFile = "doc.go" const fakePkgFile = "doc.go"
const fakePkgName = "documentation" const fakePkgName = "documentation"
// Fake relative package path for built-ins. Documentation for all globals
// (not just exported ones) will be shown for packages in this directory.
const builtinPkgPath = "builtin/"
type PageInfoMode uint type PageInfoMode uint
const ( const (
...@@ -941,7 +945,10 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -941,7 +945,10 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
relpath := r.URL.Path[len(h.pattern):] relpath := r.URL.Path[len(h.pattern):]
abspath := absolutePath(relpath, h.fsRoot) abspath := absolutePath(relpath, h.fsRoot)
mode := exportsOnly var mode PageInfoMode
if relpath != builtinPkgPath {
mode = exportsOnly
}
if r.FormValue("m") != "src" { if r.FormValue("m") != "src" {
mode |= genDoc mode |= genDoc
} }
...@@ -964,7 +971,7 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -964,7 +971,7 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
title = "Package " + info.PAst.Name.Name title = "Package " + info.PAst.Name.Name
case info.PDoc != nil: case info.PDoc != nil:
switch { switch {
case h.isPkg: case info.IsPkg:
title = "Package " + info.PDoc.PackageName title = "Package " + info.PDoc.PackageName
case info.PDoc.PackageName == fakePkgName: case info.PDoc.PackageName == fakePkgName:
// assume that the directory name is the command name // assume that the directory name is the command name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment