Skip to content

Commit 613d75c

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This documentation changes includes the following:
* Removes from `api.md` a tag used internally that prevents rendering * Removes `.md` from all links to fix those links that it breaks * Splits the scalar values tables into two to make them easier to read (proto2, proto3, editions topics) * Clarifies that Editions are supported in proto2 and editions, but not proto3 PiperOrigin-RevId: 711758660 Change-Id: I34c0585b825731cc729c7c4bf74d9a94ac6f370c
1 parent d621650 commit 613d75c

File tree

9 files changed

+289
-99
lines changed

9 files changed

+289
-99
lines changed

content/best-practices/api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<!-- go/markdown -->
2-
31
+++
42
title = "API Best Practices"
53
weight = 100

content/getting-started/kotlintutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ways to solve this problem:
3737

3838
- Use kotlinx.serialization. This does not work very well if you need to share
3939
data with applications written in C++ or Python. kotlinx.serialization has a
40-
[protobuf mode](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats.md#protobuf-experimental),
40+
[protobuf mode](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats#protobuf-experimental),
4141
but this does not offer the full features of protocol buffers.
4242
- You can invent an ad-hoc way to encode the data items into a single
4343
string -- such as encoding 4 ints as "12:3:-23:67". This is a simple and

content/programming-guides/editions.md

Lines changed: 94 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,91 @@ A scalar message field can have one of the following types – the table shows t
329329
type specified in the `.proto` file, and the corresponding type in the
330330
automatically generated class:
331331

332-
<div style="overflow:auto;width:100%;">
333-
<table style="width: 110%;">
332+
<div>
333+
<table>
334334
<tbody>
335335
<tr>
336-
<th>.proto Type</th>
336+
<th>Proto Type</th>
337337
<th>Notes</th>
338+
</tr>
339+
<tr>
340+
<td>double</td>
341+
<td></td>
342+
</tr>
343+
<tr>
344+
<td>float</td>
345+
<td></td>
346+
</tr>
347+
<tr>
348+
<td>int32</td>
349+
<td>Uses variable-length encoding. Inefficient for encoding negative
350+
numbers – if your field is likely to have negative values, use sint32
351+
instead.</td>
352+
</tr>
353+
<tr>
354+
<td>int64</td>
355+
<td>Uses variable-length encoding. Inefficient for encoding negative
356+
numbers – if your field is likely to have negative values, use sint64
357+
instead.</td>
358+
</tr>
359+
<tr>
360+
<td>uint32</td>
361+
<td>Uses variable-length encoding.</td>
362+
</tr>
363+
<tr>
364+
<td>uint64</td>
365+
<td>Uses variable-length encoding.</td>
366+
</tr>
367+
<tr>
368+
<td>sint32</td>
369+
<td>Uses variable-length encoding. Signed int value. These more
370+
efficiently encode negative numbers than regular int32s.</td>
371+
</tr>
372+
<tr>
373+
<td>sint64</td>
374+
<td>Uses variable-length encoding. Signed int value. These more
375+
efficiently encode negative numbers than regular int64s.</td>
376+
</tr>
377+
<tr>
378+
<td>fixed32</td>
379+
<td>Always four bytes. More efficient than uint32 if values are often
380+
greater than 2<sup>28</sup>.</td>
381+
</tr>
382+
<tr>
383+
<td>fixed64</td>
384+
<td>Always eight bytes. More efficient than uint64 if values are often
385+
greater than 2<sup>56</sup>.</td>
386+
</tr>
387+
<tr>
388+
<td>sfixed32</td>
389+
<td>Always four bytes.</td>
390+
</tr>
391+
<tr>
392+
<td>sfixed64</td>
393+
<td>Always eight bytes.</td>
394+
</tr>
395+
<tr>
396+
<td>bool</td>
397+
<td></td>
398+
</tr>
399+
<tr>
400+
<td>string</td>
401+
<td>A string must always contain UTF-8 encoded or 7-bit ASCII text, and cannot
402+
be longer than 2<sup>32</sup>.</td>
403+
</tr>
404+
<tr>
405+
<td>bytes</td>
406+
<td>May contain any arbitrary sequence of bytes no longer than 2<sup>32</sup>.</td>
407+
</tr>
408+
</tbody>
409+
</table>
410+
</div>
411+
412+
<div>
413+
<table style="width: 100%;overflow-x: scroll;">
414+
<tbody>
415+
<tr>
416+
<th>Proto Type</th>
338417
<th>C++ Type</th>
339418
<th>Java/Kotlin Type<sup>[1]</sup></th>
340419
<th>Python Type<sup>[3]</sup></th>
@@ -347,7 +426,6 @@ automatically generated class:
347426
</tr>
348427
<tr>
349428
<td>double</td>
350-
<td></td>
351429
<td>double</td>
352430
<td>double</td>
353431
<td>float</td>
@@ -360,7 +438,6 @@ automatically generated class:
360438
</tr>
361439
<tr>
362440
<td>float</td>
363-
<td></td>
364441
<td>float</td>
365442
<td>float</td>
366443
<td>float</td>
@@ -373,9 +450,6 @@ automatically generated class:
373450
</tr>
374451
<tr>
375452
<td>int32</td>
376-
<td>Uses variable-length encoding. Inefficient for encoding negative
377-
numbers – if your field is likely to have negative values, use sint32
378-
instead.</td>
379453
<td>int32_t</td>
380454
<td>int</td>
381455
<td>int</td>
@@ -388,9 +462,6 @@ automatically generated class:
388462
</tr>
389463
<tr>
390464
<td>int64</td>
391-
<td>Uses variable-length encoding. Inefficient for encoding negative
392-
numbers – if your field is likely to have negative values, use sint64
393-
instead.</td>
394465
<td>int64_t</td>
395466
<td>long</td>
396467
<td>int/long<sup>[4]</sup></td>
@@ -403,7 +474,6 @@ automatically generated class:
403474
</tr>
404475
<tr>
405476
<td>uint32</td>
406-
<td>Uses variable-length encoding.</td>
407477
<td>uint32_t</td>
408478
<td>int<sup>[2]</sup></td>
409479
<td>int/long<sup>[4]</sup></td>
@@ -416,7 +486,6 @@ automatically generated class:
416486
</tr>
417487
<tr>
418488
<td>uint64</td>
419-
<td>Uses variable-length encoding.</td>
420489
<td>uint64_t</td>
421490
<td>long<sup>[2]</sup></td>
422491
<td>int/long<sup>[4]</sup></td>
@@ -429,8 +498,6 @@ automatically generated class:
429498
</tr>
430499
<tr>
431500
<td>sint32</td>
432-
<td>Uses variable-length encoding. Signed int value. These more
433-
efficiently encode negative numbers than regular int32s.</td>
434501
<td>int32_t</td>
435502
<td>int</td>
436503
<td>int</td>
@@ -443,8 +510,6 @@ automatically generated class:
443510
</tr>
444511
<tr>
445512
<td>sint64</td>
446-
<td>Uses variable-length encoding. Signed int value. These more
447-
efficiently encode negative numbers than regular int64s.</td>
448513
<td>int64_t</td>
449514
<td>long</td>
450515
<td>int/long<sup>[4]</sup></td>
@@ -457,8 +522,6 @@ automatically generated class:
457522
</tr>
458523
<tr>
459524
<td>fixed32</td>
460-
<td>Always four bytes. More efficient than uint32 if values are often
461-
greater than 2<sup>28</sup>.</td>
462525
<td>uint32_t</td>
463526
<td>int<sup>[2]</sup></td>
464527
<td>int/long<sup>[4]</sup></td>
@@ -471,8 +534,6 @@ automatically generated class:
471534
</tr>
472535
<tr>
473536
<td>fixed64</td>
474-
<td>Always eight bytes. More efficient than uint64 if values are often
475-
greater than 2<sup>56</sup>.</td>
476537
<td>uint64_t</td>
477538
<td>long<sup>[2]</sup></td>
478539
<td>int/long<sup>[4]</sup></td>
@@ -485,7 +546,6 @@ automatically generated class:
485546
</tr>
486547
<tr>
487548
<td>sfixed32</td>
488-
<td>Always four bytes.</td>
489549
<td>int32_t</td>
490550
<td>int</td>
491551
<td>int</td>
@@ -498,7 +558,6 @@ automatically generated class:
498558
</tr>
499559
<tr>
500560
<td>sfixed64</td>
501-
<td>Always eight bytes.</td>
502561
<td>int64_t</td>
503562
<td>long</td>
504563
<td>int/long<sup>[4]</sup></td>
@@ -511,7 +570,6 @@ automatically generated class:
511570
</tr>
512571
<tr>
513572
<td>bool</td>
514-
<td></td>
515573
<td>bool</td>
516574
<td>boolean</td>
517575
<td>bool</td>
@@ -524,8 +582,6 @@ automatically generated class:
524582
</tr>
525583
<tr>
526584
<td>string</td>
527-
<td>A string must always contain UTF-8 encoded or 7-bit ASCII text, and cannot
528-
be longer than 2<sup>32</sup>.</td>
529585
<td>string</td>
530586
<td>String</td>
531587
<td>str/unicode<sup>[5]</sup></td>
@@ -538,10 +594,9 @@ automatically generated class:
538594
</tr>
539595
<tr>
540596
<td>bytes</td>
541-
<td>May contain any arbitrary sequence of bytes no longer than 2<sup>32</sup>.</td>
542597
<td>string</td>
543598
<td>ByteString</td>
544-
<td>str (Python 2)<br/>bytes (Python 3)</td>
599+
<td>str (Python 2), bytes (Python 3)</td>
545600
<td>[]byte</td>
546601
<td>String (ASCII-8BIT)</td>
547602
<td>ByteString</td>
@@ -1440,7 +1495,17 @@ language in the relevant [API reference](/reference/).
14401495
```
14411496

14421497
* If the parser encounters multiple members of the same oneof on the wire,
1443-
only the last member seen is used in the parsed message.
1498+
only the last run of the last member seen is used in the parsed message.
1499+
When parsing data on the wire, starting at the beginning of the bytes,
1500+
evaluate the next value, and apply the following parsing rules:
1501+
1502+
* First, check if a *different* field in the same oneof is currently set,
1503+
and if so clear it.
1504+
1505+
* Then apply the contents as though the field was not in a oneof:
1506+
1507+
* A primitive will overwrite any value already set
1508+
* A message will merge into any value already set
14441509

14451510
* Extensions are not supported for oneof.
14461511

content/programming-guides/proto-limits.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Empty message extended by singular fields (such as Boolean):
2424

2525
* ~4100 fields (proto2)
2626

27-
Extensions are supported
28-
[only by proto2](/programming-guides/version-comparison#extensionsany).
27+
Extensions are not supported in proto3.
2928

3029
To test this limitation, create a proto message with more than the upper bound
3130
number of fields and compile using a Java proto rule. The limit comes from JVM

0 commit comments

Comments
 (0)