From 2ae76fd1560b622911f444c1e66b70a857e1de67 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 1 Feb 2018 22:39:07 +0530 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Andrew Bonventre --- godoc/server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/godoc/server.go b/godoc/server.go index 95b47754..2c564656 100644 --- a/godoc/server.go +++ b/godoc/server.go @@ -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) })