]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/doc: add a line gap after a method with no comment
authorAgniva De Sarker <agnivade@yahoo.co.in>
Fri, 8 Mar 2019 06:26:16 +0000 (11:56 +0530)
committerAgniva De Sarker <agniva.quicksilver@gmail.com>
Fri, 8 Mar 2019 07:12:55 +0000 (07:12 +0000)
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>
src/cmd/doc/doc_test.go
src/cmd/doc/pkg.go
src/cmd/doc/testdata/pkg.go

index 0761c6ddb3b0fe73513c6e9e2246dd0ef5c15253..5532cf537d6adb727c4e646a49c33caf099afeb8 100644 (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`,
index 7c4e00767dcab11d60e063ef771f677169a2aec4..e3a44c42838f818d6090674a35b5db77633dff5d 100644 (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 {
index 50105b5fccce81a48d5f4c27185782c9cc84e481..88e8c215d0165816803bd686fcead4c145753de2 100644 (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