Skip to content

Commit

Permalink
Update README.md (#171)
Browse files Browse the repository at this point in the history
add highlighting code
  • Loading branch information
DariushStony authored Jul 29, 2023
1 parent 566f359 commit 8730ba5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ For Closure imports, `protoc` will generate a single output file
(`myproto_libs.js` in this example). The generated file will `goog.provide()`
all of the types defined in your .proto files. For example, for the unit
tests the generated files contain many `goog.provide` statements like:

```js
goog.provide('proto.google.protobuf.DescriptorProto');
goog.provide('proto.google.protobuf.DescriptorProto.ExtensionRange');
goog.provide('proto.google.protobuf.DescriptorProto.ReservedRange');
goog.provide('proto.google.protobuf.EnumDescriptorProto');
goog.provide('proto.google.protobuf.EnumOptions');

```
The generated code will also `goog.require()` many types in the core library,
and they will require many types in the Google Closure library. So make sure
that your `goog.provide()` / `goog.require()` setup can find all of your
Expand All @@ -107,11 +107,11 @@ Google Closure library itself.

Once you've done this, you should be able to import your types with
statements like:

```js
goog.require('proto.my.package.MyMessage');

var message = proto.my.package.MyMessage();

```
If unfamiliar with Closure or its compiler, consider reviewing
[Closure documentation](https://developers.google.com/closure/library).

Expand All @@ -134,11 +134,11 @@ to build it first by running:

Once you've done this, you should be able to import your types with
statements like:

```js
var messages = require('./messages_pb');

var message = new messages.MyMessage();

```
The `--js_out` flag
-------------------

Expand All @@ -165,7 +165,7 @@ API

The API is not well-documented yet. Here is a quick example to give you an
idea of how the library generally works:

```js
var message = new MyMessage();

message.setName("John Doe");
Expand All @@ -176,6 +176,6 @@ idea of how the library generally works:
var bytes = message.serializeBinary();

var message2 = MyMessage.deserializeBinary(bytes);

```
For more examples, see the tests. You can also look at the generated code
to see what methods are defined for your generated messages.

0 comments on commit 8730ba5

Please sign in to comment.