From b10409711cb271f4ea881839af2782517928623f Mon Sep 17 00:00:00 2001 From: Marcus Longmuir Date: Fri, 26 Jan 2018 16:55:33 +0000 Subject: [PATCH] Fixed code highlighting --- ts/README.md | 6 +++--- ts/docs/code-generation.md | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ts/README.md b/ts/README.md index 38a36280..1d2920a2 100644 --- a/ts/README.md +++ b/ts/README.md @@ -59,14 +59,14 @@ There are three functions for making gRPC requests: ### [`grpc.unary`](docs/unary.md) This is a convenience function for making requests that consist of a single request message and single response message. It can only be used with unary methods. -``` +```protobuf rpc GetBook(GetBookRequest) returns (Book) {} ``` ### [`grpc.invoke`](docs/invoke.md) This is a convenience function for making requests that consist of a single request message and a stream of response messages (server-streaming). It can also be used with unary methods. -``` +```protobuf rpc GetBook(GetBookRequest) returns (Book) {} rpc QueryBooks(QueryBooksRequest) returns (stream Book) {} ``` @@ -74,7 +74,7 @@ rpc QueryBooks(QueryBooksRequest) returns (stream Book) {} ### [`grpc.client`](docs/client.md) `grpc.client` returns a client. Dependant upon [transport compatibility](docs/transport) this client is capable of sending multiple request messages (client-streaming) and receiving multiple response messages (server-streaming). It can be used with any type of method, but will enforce limiting the sending of messages for unary methods. -``` +```protobuf rpc GetBook(GetBookRequest) returns (Book) {} rpc QueryBooks(QueryBooksRequest) returns (stream Book) {} rpc LogReadPages(stream PageRead) returns (google.protobuf.Empty) {} diff --git a/ts/docs/code-generation.md b/ts/docs/code-generation.md index 2dbe87a6..0f6fc8cc 100644 --- a/ts/docs/code-generation.md +++ b/ts/docs/code-generation.md @@ -6,13 +6,13 @@ To make gRPC requests the client requires generated code for the [method definit This process is slightly different between TypeScript and JavaScript usage. -### TypeScript ([skip to JS](#JavaScript)) +### TypeScript ([skip to JS](#javascript)) [`ts-protoc-gen`](https://www.github.com/improbable-eng/ts-protoc-gen) is a package that can generate the `.d.ts` files that declare the contents of the protoc-generated JavaScript files. `ts-protoc-gen` can also generate `grpc-web-client` service/method definitions with the `protoc-gen-ts` plugin and `service=true` argument. This is an example of a complete invokation of `protoc` with `ts-protoc-gen` assuming your `.proto` files are in a directory named `my-protos` within the current working directory: -``` +```bash protoc \ --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ --js_out=import_style=commonjs,binary:my-generated-code \ @@ -23,23 +23,24 @@ my-protos/*.proto A proto file such as `book_service.proto`: -```syntax = "proto3"; +```protobuf +syntax = "proto3"; - package examplecom.library; +package examplecom.library; - message Book { - int64 isbn = 1; - string title = 2; - string author = 3; - } +message Book { + int64 isbn = 1; + string title = 2; + string author = 3; +} - message GetBookRequest { - int64 isbn = 1; - } +message GetBookRequest { + int64 isbn = 1; +} - service BookService { - rpc GetBook(GetBookRequest) returns (Book) {} - } +service BookService { + rpc GetBook(GetBookRequest) returns (Book) {} +} ``` Will generate `book_service_pb.js`, `book_service_pb.d.ts` and `book_service_pb_service.ts`. @@ -53,7 +54,7 @@ The first two files contain the message classes and `book_service_pb_service.ts` This is an example of a complete invokation of `protoc` with `ts-protoc-gen` assuming your `.proto` files are in a directory named `my-protos` within the current working directory: -``` +```bash protoc \ --plugin=protoc-gen-js_service=./node_modules/.bin/protoc-gen-js_service \ --js_out=import_style=commonjs,binary:my-generated-code \