Skip to content

Commit

Permalink
README fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
onokonem committed Oct 31, 2024
1 parent c5dcd5c commit b80ff06
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -29,7 +29,7 @@ Exactly the same as any other protoc plugin.

#### Parameters

```
```txt
protoc plugin to generate Python gRPC code
Usage:
Expand All @@ -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.
Expand Down

0 comments on commit b80ff06

Please sign in to comment.