Skip to content

Commit

Permalink
cmd/doc: add a line gap after a method with no comment
Browse files Browse the repository at this point in the history
Fixes golang#30492

Change-Id: Iec658bdf8bfac21e1bcc3eed900722cc535ec00a
Reviewed-on: https://go-review.googlesource.com/c/go/+/166178
Run-TryBot: Agniva De Sarker <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Rob Pike <[email protected]>
  • Loading branch information
agnivade committed Mar 8, 2019
1 parent 6c6a0a1 commit 055f16a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/doc/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/doc/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/doc/testdata/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 055f16a

Please sign in to comment.