internal/godoc/dochtml: return empty string if doc is empty

Previously, if there was no documentation "<div
class="Documentation-content js-docContent"> </div>" was returned. The
empty string is now returned if the unit page experiment is on.

Change-Id: I4f16f87d50c054bcaf8d87661d0e5cdfbf223645
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/260732
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/godoc/dochtml/dochtml.go b/internal/godoc/dochtml/dochtml.go
index 2967289..e2d8d59 100644
--- a/internal/godoc/dochtml/dochtml.go
+++ b/internal/godoc/dochtml/dochtml.go
@@ -25,7 +25,9 @@
 	"github.com/google/safehtml/legacyconversions"
 	"github.com/google/safehtml/template"
 	"github.com/google/safehtml/uncheckedconversions"
+	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/godoc/dochtml/internal/render"
 	"golang.org/x/pkgsite/internal/godoc/internal/doc"
 )
@@ -117,6 +119,17 @@
 		return linkHTML(name, opt.SourceLinkFunc(node), "Documentation-source")
 	}
 
+	if experiment.IsActive(ctx, internal.ExperimentUnitPage) {
+		if p.Doc == "" &&
+			len(p.Examples) == 0 &&
+			len(p.Consts) == 0 &&
+			len(p.Vars) == 0 &&
+			len(p.Types) == 0 &&
+			len(p.Funcs) == 0 {
+			return safehtml.HTML{}, nil
+		}
+	}
+
 	h := htmlPackage(ctx)
 	tmpl := template.Must(h.Clone()).Funcs(map[string]interface{}{
 		"render_short_synopsis": r.ShortSynopsis,