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 <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Agniva De Sarker 2019-03-08 11:56:16 +05:30 committed by Agniva De Sarker
parent 6c6a0a1f2a
commit 055f16a9e9
3 changed files with 8 additions and 0 deletions

View file

@ -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`,

View file

@ -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 {

View file

@ -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