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>
diff --git a/godoc/server.go b/godoc/server.go
index 95b4775..2c56465 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -200,11 +200,12 @@
 		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) })