1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:04:46 -07:00

godoc: show synopses for subdirectories in package view

In command-line mode, we were traversing the dir tree with depth
of only 1. This prevented the synopses of sub-directories from being
scanned and showed in the output when a package path was being passed.

Increasing the depth to 2 so that sub-directories of the next
level is also parsed and the synopses gets shown.

Also fixed the comment to reflect that dir can be nil only in
command-line mode now after golang.org/cl/93215

Fixes golang/go#22646

Change-Id: I066a3bc3ba3d9d3a9589f97137e1bc4497a45473
Reviewed-on: https://go-review.googlesource.com/93675
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Agniva De Sarker 2018-02-01 22:39:07 +05:30 committed by Andrew Bonventre
parent 86e0f6745d
commit 2ae76fd156

View File

@ -200,11 +200,12 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode,
timestamp = ts
}
if dir == nil {
// no directory tree present (too early after startup or
// command-line mode); compute one level for this page
// no directory tree present (happens in command-line mode);
// compute 2 levels for this page. The second level is to
// get the synopses of sub-directories.
// note: cannot use path filter here because in general
// it doesn't contain the FSTree path
dir = h.c.newDirectory(abspath, 1)
// it doesn't contain the FSTree path
dir = h.c.newDirectory(abspath, 2)
timestamp = time.Now()
}
info.Dirs = dir.listing(true, func(path string) bool { return h.includePath(path, mode) })