diff options
| author | Russ Cox <rsc@golang.org> | 2021-02-26 00:24:58 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-06-08 20:20:20 +0000 |
| commit | 9d7d9c7a5d3eedff752accd1ffde24085e633a26 (patch) | |
| tree | 5144bfffbe5683d21363072dd5b68eafe815a54b | |
| parent | 72dd19b3a4e2e5eb8721a1cc661a218985b05cc2 (diff) | |
| download | go-x-website-9d7d9c7a5d3eedff752accd1ffde24085e633a26.tar.xz | |
all: remove ?m=src
Instead of /pkg/fmt/?m=src people can use /src/pkg/fmt/.
Change-Id: I77dd11dcfa1b3e8d660e9cda6a5f07dbb60d721b
Reviewed-on: https://go-review.googlesource.com/c/website/+/317654
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Website-Publish: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
| -rw-r--r-- | _content/lib/godoc/package.html | 6 | ||||
| -rw-r--r-- | _content/lib/godoc/packageroot.html | 5 | ||||
| -rw-r--r-- | internal/godoc/server.go | 5 | ||||
| -rw-r--r-- | internal/pkgdoc/doc.go | 96 |
4 files changed, 41 insertions, 71 deletions
diff --git a/_content/lib/godoc/package.html b/_content/lib/godoc/package.html index 1e36fff0..9f0c8793 100644 --- a/_content/lib/godoc/package.html +++ b/_content/lib/godoc/package.html @@ -192,12 +192,6 @@ {{end}} {{end}} -{{with .PAst}} - {{range $filename, $ast := .}} - <a href="{{$filename|srcLink|html}}">{{$filename|filename|html}}</a>:<pre>{{node_html $ $ast false}}</pre> - {{end}} -{{end}} - {{with .Dirs}} {{/* DirList entries are numbers and strings - no need for FSet */}} {{if $.PDoc}} diff --git a/_content/lib/godoc/packageroot.html b/_content/lib/godoc/packageroot.html index 2b5c5e6f..5727926c 100644 --- a/_content/lib/godoc/packageroot.html +++ b/_content/lib/godoc/packageroot.html @@ -9,11 +9,6 @@ them to conflict with generated attributes (some of which correspond to Go identifiers). --> -{{with .PAst}} - {{range $filename, $ast := .}} - <a href="{{$filename|srcLink|html}}">{{$filename|filename|html}}</a>:<pre>{{node_html $ $ast false}}</pre> - {{end}} -{{end}} {{with .Dirs}} {{/* DirList entries are numbers and strings - no need for FSet */}} diff --git a/internal/godoc/server.go b/internal/godoc/server.go index 7b3c8147..c10b189a 100644 --- a/internal/godoc/server.go +++ b/internal/godoc/server.go @@ -66,11 +66,6 @@ func (h *docServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { var tabtitle, title, subtitle string switch { - case info.PAst != nil: - for _, ast := range info.PAst { - tabtitle = ast.Name.Name - break - } case info.PDoc != nil: tabtitle = info.PDoc.Name default: diff --git a/internal/pkgdoc/doc.go b/internal/pkgdoc/doc.go index 219e673b..a5b98aca 100644 --- a/internal/pkgdoc/doc.go +++ b/internal/pkgdoc/doc.go @@ -51,13 +51,12 @@ type Page struct { Mode Mode // display metadata from query string // package info - FSet *token.FileSet // nil if no package documentation - PDoc *doc.Package // nil if no package documentation - Examples []*doc.Example // nil if no example code - Bugs []*doc.Note // nil if no BUG comments - PAst map[string]*ast.File // nil if no AST with package exports - IsMain bool // true for package main - IsFiltered bool // true if results were filtered + FSet *token.FileSet // nil if no package documentation + PDoc *doc.Package // nil if no package documentation + Examples []*doc.Example // nil if no example code + Bugs []*doc.Note // nil if no BUG comments + IsMain bool // true for package main + IsFiltered bool // true if results were filtered // directory info Dirs *DirList // nil if no directory information @@ -65,7 +64,7 @@ type Page struct { } func (info *Page) IsEmpty() bool { - return info.Err != nil || info.PAst == nil && info.PDoc == nil && info.Dirs == nil + return info.Err != nil || info.PDoc == nil && info.Dirs == nil } type Mode uint @@ -74,7 +73,6 @@ const ( ModeAll Mode = 1 << iota // do not filter exports ModeFlat // show directory in a flat (non-indented) manner ModeMethods // show all embedded methods - ModeSrc // show source code, do not extract documentation ModeBuiltin // don't associate consts, vars, and factory functions with types (not exposed via ?m= query parameter, used for package builtin, see issue 6645) ) @@ -84,7 +82,6 @@ var modeNames = []string{ "all", "flat", "methods", - "src", } // generate a query string for persisting PageInfoMode between pages. @@ -116,12 +113,11 @@ func ParseMode(text string) Mode { return mode } -// GetPageInfo returns the PageInfo for a package directory abspath. If the -// parameter genAST is set, an AST containing only the package exports is -// computed (PageInfo.PAst), otherwise package documentation (PageInfo.Doc) -// is extracted from the AST. If there is no corresponding package in the -// directory, PageInfo.PAst and PageInfo.PDoc are nil. If there are no sub- -// directories, PageInfo.Dirs is nil. If an error occurred, PageInfo.Err is +// Doc returns the Page for a package directory abspath. +// Package documentation (Page.PDoc) is extracted from the AST. +// If there is no corresponding package in the +// directory, Page.PDoc is nil. If there are no sub- +// directories, Page.Dirs is nil. If an error occurred, PageInfo.Err is // set to the respective error but the error is not logged. func Doc(d *Docs, abspath, relpath string, mode Mode, goos, goarch string) *Page { info := &Page{Dirname: abspath, Mode: mode} @@ -209,48 +205,38 @@ func Doc(d *Docs, abspath, relpath string, mode Mode, goos, goarch string) *Page // extract package documentation info.FSet = fset - if mode&ModeSrc == 0 { - // show extracted documentation - var m doc.Mode - if mode&ModeAll != 0 { - m |= doc.AllDecls - } - if mode&ModeMethods != 0 { - m |= doc.AllMethods - } - info.PDoc = doc.New(pkg, path.Clean(relpath), m) // no trailing '/' in importpath - if mode&ModeBuiltin != 0 { - for _, t := range info.PDoc.Types { - info.PDoc.Consts = append(info.PDoc.Consts, t.Consts...) - info.PDoc.Vars = append(info.PDoc.Vars, t.Vars...) - info.PDoc.Funcs = append(info.PDoc.Funcs, t.Funcs...) - t.Consts = nil - t.Vars = nil - t.Funcs = nil - } - // for now we cannot easily sort consts and vars since - // go/doc.Value doesn't export the order information - sort.Sort(funcsByName(info.PDoc.Funcs)) + info.IsMain = pkgname == "main" + // show extracted documentation + var m doc.Mode + if mode&ModeAll != 0 { + m |= doc.AllDecls + } + if mode&ModeMethods != 0 { + m |= doc.AllMethods + } + info.PDoc = doc.New(pkg, path.Clean(relpath), m) // no trailing '/' in importpath + if mode&ModeBuiltin != 0 { + for _, t := range info.PDoc.Types { + info.PDoc.Consts = append(info.PDoc.Consts, t.Consts...) + info.PDoc.Vars = append(info.PDoc.Vars, t.Vars...) + info.PDoc.Funcs = append(info.PDoc.Funcs, t.Funcs...) + t.Consts = nil + t.Vars = nil + t.Funcs = nil } + // for now we cannot easily sort consts and vars since + // go/doc.Value doesn't export the order information + sort.Sort(funcsByName(info.PDoc.Funcs)) + } - // collect examples - testfiles := append(pkginfo.TestGoFiles, pkginfo.XTestGoFiles...) - files, err = parseFiles(d.fs, fset, relpath, abspath, testfiles) - if err != nil { - log.Println("parsing examples:", err) - } - info.Examples = collectExamples(pkg, files) - info.Bugs = info.PDoc.Notes["BUG"] - } else { - // show source code - // TODO(gri) Consider eliminating export filtering in this mode, - // or perhaps eliminating the mode altogether. - if mode&ModeAll == 0 { - packageExports(fset, pkg) - } - info.PAst = files + // collect examples + testfiles := append(pkginfo.TestGoFiles, pkginfo.XTestGoFiles...) + files, err = parseFiles(d.fs, fset, relpath, abspath, testfiles) + if err != nil { + log.Println("parsing examples:", err) } - info.IsMain = pkgname == "main" + info.Examples = collectExamples(pkg, files) + info.Bugs = info.PDoc.Notes["BUG"] } info.Dirs = d.root.Lookup(abspath).List(func(path string) bool { return d.includePath(path, mode) }) |
