Add @deprecated tag for doc block for service, method and message (#12265)

At the moment, `protoc` ignores `option deprecated = true` for these entities.

It seems good to add the tag `@deprecated` to highlight the deprecation in the client code. It works for fields bot not for messages/service/method.

I wanted to add the test for this change, but I couldn't find any test for the generator. I will be happy if you can guide me in the right direction

Closes #12265

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12265 from negram:add-message-deprecate fa52e15366
PiperOrigin-RevId: 518007790
pull/12242/head
Mikhail Galanin 2 years ago committed by Copybara-Service
parent 540e64febb
commit c63316fad1
  1. 13
      src/google/protobuf/compiler/php/php_generator.cc

@ -1732,6 +1732,10 @@ void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message,
const Options& options) {
printer->Print("/**\n");
GenerateDocCommentBody(printer, message);
if (message->options().deprecated()) {
printer->Print(" * @deprecated\n");
}
printer->Print(
" * Generated from protobuf message <code>^messagename^</code>\n"
" */\n",
@ -1773,6 +1777,9 @@ void GenerateMessageConstructorDocComment(io::Printer* printer,
void GenerateServiceDocComment(io::Printer* printer,
const ServiceDescriptor* service) {
printer->Print("/**\n");
if (service->options().deprecated()) {
printer->Print(" * @deprecated\n");
}
GenerateDocCommentBody(printer, service);
printer->Print(
" * Protobuf type <code>^fullname^</code>\n"
@ -1850,6 +1857,9 @@ void GenerateWrapperFieldSetterDocComment(io::Printer* printer, const FieldDescr
void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_,
const Options& options) {
printer->Print("/**\n");
if (enum_->options().deprecated()) {
printer->Print(" * @deprecated\n");
}
GenerateDocCommentBody(printer, enum_);
printer->Print(
" * Protobuf type <code>^fullname^</code>\n"
@ -1871,6 +1881,9 @@ void GenerateServiceMethodDocComment(io::Printer* printer,
const MethodDescriptor* method) {
printer->Print("/**\n");
GenerateDocCommentBody(printer, method);
if (method->options().deprecated()) {
printer->Print(" * @deprecated\n");
}
printer->Print(
" * Method <code>^method_name^</code>\n"
" *\n",

Loading…
Cancel
Save