From c63316fad152007c1aa0208ebbc7b110beb5fa7f Mon Sep 17 00:00:00 2001 From: Mikhail Galanin Date: Mon, 20 Mar 2023 10:26:58 -0700 Subject: [PATCH] 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 fa52e15366859508d8f8aac269a20409fc856220 PiperOrigin-RevId: 518007790 --- src/google/protobuf/compiler/php/php_generator.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index d8d1630e90..392ca368d8 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/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 ^messagename^\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 ^fullname^\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 ^fullname^\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 ^method_name^\n" " *\n",