Only leading comments
This rule enforces that every descriptor in every proto file has a public comment information only in leading comment (not trailing comments or detached comments), as mandated in AIP-192.
Details
This rule looks at each descriptor in each proto file (exempting oneofs and the file itself) and complains if public comments are either trailing or detached. Internal comments are not considered.
Examples
Incorrect code for this rule:
// Incorrect.
// BEGIN LIBRARY SECTION <-- detached comment; shows up in docs.
// A representation of a book.
message Book {
// The resource name of the book.
string name = 1;
}
Correct code for this rule:
// Correct.
// (-- BEGIN LIBRARY SECTION --)
// A representation of a book.
message Book {
// The resource name of the book.
string name = 1;
}
Disabling
If you need to violate this rule, use a leading comment above the descriptor (and revel in the irony). Remember to also include an aip.dev/not-precedent comment explaining why.
// BEGIN LIBRARY SECTION <-- detached comment; shows up in docs.
// A representation of a book.
// (-- api-linter: core::0192::only-leading-comments=disabled
// aip.dev/not-precedent: We need to do this because reasons. --)
message Book {
// The resource name of the book.
string name = 1;
}