protobuf-go/cmd/protoc-gen-go/testdata/comments/comments.proto
Joe Tsai 8d5e6d6927 cmd/protoc-gen-go: improve generation of comments
The following improvements were made:
* All standalone comments above the "syntax" marker are preserved
similar to Java and some other generators.
* All standalone comments above the "package" marker are preserved
to be consistent with our former behavior.
* Leading comments are now generated for enums and extension fields.
* Single-line trailing comments are now generated for
enum values, message fields, and extension fields.
* The leading comments for each field that is part of a oneof are now
generated with the wrapper types rather than being shoved into the
comment for the oneof itself in an unreadable way.
* The deprecation marker is always generated as being above the declaration
rather than sometimes being an inlined comment.
* The deprecation marker is now properly generated for weak field setters.

Updates golang/protobuf#666

Change-Id: I7fd832dd4f86d15bfff70d7c22c6ba4934c05fcf
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/189238
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-07 17:33:08 +00:00

62 lines
1.4 KiB
Protocol Buffer

// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
syntax = "proto2";
// COMMENT: package goproto.protoc.comments;
package goproto.protoc.comments;
option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/comments";
// COMMENT: Enum1.Leading
enum Enum1 {
// COMMENT: FOO.Leading
FOO = 0; // COMMENT: FOO.InlineTrailing
// COMMENT: BAR.Leading
BAR = 1;
// COMMENT: BAR.Trailing1
// COMMENT: BAR.Trailing2
// COMMENT: Enum1.EndBody
}
// COMMENT: Message1.Leading
message Message1 {
// COMMENT: Message1A.Leading
message Message1A {
} // COMMENT: Message1A.Trailing
// COMMENT: Message1B
message Message1B {
}
// COMMENT: Field1A.Leading
optional string Field1A = 1; // COMMENT: Field1A.Trailing
// COMMENT: Oneof1A.Leading
oneof Oneof1a {
// COMMENT: Oneof1AField1.Leading
string Oneof1AField1 = 2; // COMMENT: Oneof1AField1.Trailing
} // COMMENT: Oneof1A.Trailing
extensions 100 to max;
} // COMMENT: Message1.Trailing
// COMMENT: Extend
extend Message1 {
// COMMENT: Extension.Leading
optional Message1 extension = 100; // COMMENT: Extension.Trailing
}
// COMMENT: Message2
message Message2 {
// COMMENT: Message2A
message Message2A {
}
// COMMENT: Message2B
message Message2B {
}
}