From b80ff06e13cd79d914aa1b9c6ad5b6424ab84697 Mon Sep 17 00:00:00 2001 From: Daniel Podolsky <1049874+onokonem@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:55:00 +0300 Subject: [PATCH] README fixed --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5c79717..5283df9 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ Input is exactly the same as any other protoc plugin. Output is exactly the same as the [good old protoc-gen-python-grpc](https://github.com/grpc/grpc/blob/master/src/compiler/python_generator.cc) provides. -Please rise the issue in case of any difference found in these plugins output. +Please rise the issue in case of any difference found in these plugins output. ## How it works ### Install -``` -go install github.com/Djarvur/protoc-gen-python-grpc/cmd/protoc-gen-python-grpc@v0.1.5 +```sh +go install github.com/Djarvur/protoc-gen-python-grpc/cmd/protoc-gen-python-grpc@v0.1.7 ``` Make sure your [protoc](https://grpc.io/docs/protoc-installation/)/[buf](https://buf.build/docs/installation) compiler can see the `protoc-gen-python-grpc` in the path. @@ -29,7 +29,7 @@ Exactly the same as any other protoc plugin. #### Parameters -``` +```txt protoc plugin to generate Python gRPC code Usage: @@ -48,28 +48,32 @@ There is the embedded template for the `_pb2_grpc.py` files in the program. Of course, you can provide your own in Go [text/template](https://pkg.go.dev/text/template) format utilising the following placeholders: For each file: + - `{{.Name}}` - name of the source file as it is provided by protoc/buf - `{{.Package}}` - proto package name - `{{.Services}}` - list of the services defined in the proto file (see below) For each service: + - `{{.Name}}` - name of the service - `{{.Comment}}` - service-related comment, might be multi-line - `{{.Methods}}` - list of the methods defined for this service in proto file (see below) For each method: + - `{{.Name}}` - name of the method - `{{.Comment}}` - method-related comment, might be multi-line -- `{{.Request}}` - name of the method request message -- `{{.Response}}` - name of the method response message +- `{{.Request}}` - name of the method request message +- `{{.Response}}` - name of the method response message - `{{.ClientStreaming}}` - boolean indicates is this method client-streaming - `{{.ServerStreaming}}` - boolean indicates is this method server-streaming Also, the following functions are available to be used as template pipelines: + - `{{trimSuffix separator value}}` - returns a substring with the after-the-last-separator part removed - `{{baseName separator value}}` - returns a substring after-the-last-separator - `{{replace from to value}}` - returns a string with all the occurrences of `from` replaced to `to` -- `{{split separator value}}` - splitting value by separator and returns a list of substrings +- `{{split separator value}}` - splitting value by separator and returns a list of substrings - `{{join separator ...values}}` - joining a values list to one string with values divided by separator See [embedded template](cmd/protoc-gen-python-grpc/internal/flags/pb2_grpc.py.tmpl) for example.