]> Cypherpunks repositories - gostls13.git/commit
go/printer: do not treat comments inside a ast.Decl as godoc
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Wed, 4 Sep 2024 07:05:17 +0000 (07:05 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 5 Sep 2024 18:53:36 +0000 (18:53 +0000)
commitc3f16307b3ff28578c915b8513f6369ad9f5e8f3
treeb38371e271c383a67bd22071bc9d7f76cce4763e
parent89958ab4aef14982b344c3d4aab8a93a9ad60f12
go/printer: do not treat comments inside a ast.Decl as godoc

This change makes sure that we do not format comments
as doc comments inside of a declaration and makes the
go doc formatter idempotent:

Previously:

// test comment
//go:directive2
// test comment
func main() {
}

was formatted to:

// test comment
//go:directive2
// test comment
func main() {
}

after another formatting, it got formatted with doc rules into:

// test comment
// test comment
//
//go:directive2
func main() {
}

With this change it gets directly to the correct form (last one).

Change-Id: Id7d8f03e43474357cd714e0672e886652c3fce86
GitHub-Last-Rev: 9833b87536c29f8be0e74c232936c5e6c5a9b78b
GitHub-Pull-Request: golang/go#69134
Reviewed-on: https://go-review.googlesource.com/c/go/+/609077
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
src/go/printer/nodes.go
src/go/printer/printer.go
src/go/printer/printer_test.go