From 055f16a9e9fb7ba7e1360b40e5924cc7ba95317c Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 8 Mar 2019 11:56:16 +0530 Subject: [PATCH] cmd/doc: add a line gap after a method with no comment Fixes #30492 Change-Id: Iec658bdf8bfac21e1bcc3eed900722cc535ec00a Reviewed-on: https://go-review.googlesource.com/c/go/+/166178 Run-TryBot: Agniva De Sarker TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- src/cmd/doc/doc_test.go | 1 + src/cmd/doc/pkg.go | 3 +++ src/cmd/doc/testdata/pkg.go | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/cmd/doc/doc_test.go b/src/cmd/doc/doc_test.go index 0761c6ddb3b0fe..5532cf537d6adb 100644 --- a/src/cmd/doc/doc_test.go +++ b/src/cmd/doc/doc_test.go @@ -496,6 +496,7 @@ var tests = []test{ `func ReturnExported\(\) ExportedType`, `func \(ExportedType\) ExportedMethod\(a int\) bool`, `Comment about exported method.`, + `func \(ExportedType\) Uncommented\(a int\) bool\n\n`, // Ensure line gap after method with no comment }, []string{ `unexportedType`, diff --git a/src/cmd/doc/pkg.go b/src/cmd/doc/pkg.go index 7c4e00767dcab1..e3a44c42838f81 100644 --- a/src/cmd/doc/pkg.go +++ b/src/cmd/doc/pkg.go @@ -808,6 +808,9 @@ func (pkg *Package) typeDoc(typ *doc.Type) { for _, fun := range funcs { if isExported(fun.Name) { pkg.emit(fun.Doc, fun.Decl) + if fun.Doc == "" { + pkg.newlines(2) + } } } } else { diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go index 50105b5fccce81..88e8c215d01658 100644 --- a/src/cmd/doc/testdata/pkg.go +++ b/src/cmd/doc/testdata/pkg.go @@ -80,6 +80,10 @@ func (ExportedType) ExportedMethod(a int) bool { return true != true } +func (ExportedType) Uncommented(a int) bool { + return true != true +} + // Comment about unexported method. func (ExportedType) unexportedMethod(a int) bool { return true