Skip to content

Commit d2a97bb

Browse files
committed
Docs: Documented internally used codegen partials for what it's worth
1 parent a08ee23 commit d2a97bb

23 files changed

+281
-215
lines changed

README.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -167,35 +167,16 @@ Custom classes are automatically populated with static `encode`, `encodeDelimite
167167

168168
### Using the Reader/Writer interface directly
169169

170-
While only useful for the adventurous cherishing an aversion to [generated static code](https://github.com/dcodeIO/protobuf.js#command-line), it's also possible to use the Reader/Writer interface directly using just the [minimal runtime](https://github.com/dcodeIO/protobuf.js/tree/master/dist/runtime) to build custom encoders and decoders that work accross modern to ancient browsers and, of course, node:
171-
172-
```js
173-
var writer = protobuf.Writer.create();
174-
var buffer = writer
175-
.uint32(/* id */ 1 << 3 | /* wireType */ 2)
176-
.string("hello world!")
177-
.finish();
178-
179-
var reader = protobuf.Reader.create(buffer);
180-
while (reader.pos < reader.len) {
181-
var tag = reader.uint32();
182-
switch (/* id */ tag >>> 3) {
183-
case 1:
184-
console.log(reader.string());
185-
break;
186-
default:
187-
reader.skipType(/* wireType */ tag & 7);
188-
break;
189-
}
190-
}
191-
```
170+
While only useful for the adventurous cherishing an aversion to [generated static code](https://github.com/dcodeIO/protobuf.js#command-line), it's also possible to use the Reader/Writer interface directly depending just on the [minimal runtime](https://github.com/dcodeIO/protobuf.js/tree/master/dist/runtime) ([basic example](https://github.com/dcodeIO/protobuf.js/blob/master/examples/reader-writer.js)).
192171

193172
Easy ways to obtain example code snippets are either setting `protobuf.util.codegen.verbose = true` while watching the magic as it happens, or simply inspecting generated static code.
194173

195174
### Using services
196175

197176
```protobuf
198177
// greeter.proto
178+
syntax = "proto3";
179+
199180
service Greeter {
200181
rpc SayHello (HelloRequest) returns (HelloReply) {}
201182
}

0 commit comments

Comments
 (0)