mirror of
https://github.com/golang/go
synced 2024-11-23 17:30:02 -07:00
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:
parent
6c6a0a1f2a
commit
055f16a9e9
@ -496,6 +496,7 @@ var tests = []test{
|
|||||||
`func ReturnExported\(\) ExportedType`,
|
`func ReturnExported\(\) ExportedType`,
|
||||||
`func \(ExportedType\) ExportedMethod\(a int\) bool`,
|
`func \(ExportedType\) ExportedMethod\(a int\) bool`,
|
||||||
`Comment about exported method.`,
|
`Comment about exported method.`,
|
||||||
|
`func \(ExportedType\) Uncommented\(a int\) bool\n\n`, // Ensure line gap after method with no comment
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
`unexportedType`,
|
`unexportedType`,
|
||||||
|
@ -808,6 +808,9 @@ func (pkg *Package) typeDoc(typ *doc.Type) {
|
|||||||
for _, fun := range funcs {
|
for _, fun := range funcs {
|
||||||
if isExported(fun.Name) {
|
if isExported(fun.Name) {
|
||||||
pkg.emit(fun.Doc, fun.Decl)
|
pkg.emit(fun.Doc, fun.Decl)
|
||||||
|
if fun.Doc == "" {
|
||||||
|
pkg.newlines(2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
4
src/cmd/doc/testdata/pkg.go
vendored
4
src/cmd/doc/testdata/pkg.go
vendored
@ -80,6 +80,10 @@ func (ExportedType) ExportedMethod(a int) bool {
|
|||||||
return true != true
|
return true != true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ExportedType) Uncommented(a int) bool {
|
||||||
|
return true != true
|
||||||
|
}
|
||||||
|
|
||||||
// Comment about unexported method.
|
// Comment about unexported method.
|
||||||
func (ExportedType) unexportedMethod(a int) bool {
|
func (ExportedType) unexportedMethod(a int) bool {
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user