0

I'm trying to figure out how to make my comments in my .proto file appear in the files generated for Python by protoc.

I have a proto file service.proto. In it I have added comments on some of the messages as well as on some of the fields. So for example:

// Comment regarding this message in general
message StepConfiguration {
    // Comment regarding this field
    bool skip_step = 1;
}

I have tried to execute the following command: python -m grpc_tools.protoc -I protos/V1/ --python_out=client/ --pyi_out=client/ --grpc_python_out=client/ protos/V1/service.proto

This will generate the following 3 files:

  • client\service_pb2.py
  • client\service_pb2.pyi
  • client\service_pb2_grpc.py

If I look through these 3 files, none of my comments carry over into them from the proto file. Is there any way to configure protoc to do this? Or is there another tool I can use in combination with protoc to do this?

My main goal is for PyCharm to be able to present these comments when using the generated code.

Other information of possible relevance:

  • When I generate C# classes in Visual Studio 2022 from a proto file, it will automatically include the comments from the proto file as XML docs on the generated items.
ChrisH
  • 1
  • 1

0 Answers0