Skip to content

Commit d621650

Browse files
authored
Merge pull request #210 from Logofile/sync
Documentation update
2 parents ff6e4e1 + 64d6279 commit d621650

File tree

20 files changed

+152
-119
lines changed

20 files changed

+152
-119
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

content/editions/implementation.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ language-appropriate naming:
188188
delimited encoding
189189
* `EnumDescriptor::is_closed` - Whether or not a field is closed
190190

191-
**Note:** In most languages, the message encoding feature is still currently
192-
signaled by `TYPE_GROUP` and required fields still have `LABEL_REQUIRED` set.
193-
This is not ideal, and was done to make downstream migrations easier.
194-
Eventually, these should be migrated to the appropriate helpers and
195-
`TYPE_MESSAGE/LABEL_OPTIONAL`.
191+
{{% alert title="Note" color="note" %}} In
192+
most languages, the message encoding feature is still currently signaled by
193+
`TYPE_GROUP` and required fields still have `LABEL_REQUIRED` set. This is not
194+
ideal, and was done to make downstream migrations easier. Eventually, these
195+
should be migrated to the appropriate helpers and
196+
`TYPE_MESSAGE/LABEL_OPTIONAL`.{{% /alert %}}
196197

197198
Downstream users should migrate to these new helpers instead of using syntax
198199
directly. The following class of existing descriptor APIs should ideally be

content/editions/overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ package com.example;
9999
100100
message Player {
101101
// in proto2, optional fields have explicit presence
102-
optional string name = 1;
102+
optional string name = 1 [default = "N/A"];
103103
// proto2 still supports the problematic "required" field rule
104104
required int32 id = 2;
105105
// in proto2 this is not packed by default
@@ -129,7 +129,7 @@ package com.example;
129129
130130
message Player {
131131
// fields have explicit presence, so no explicit setting needed
132-
string name = 1;
132+
string name = 1 [default = "N/A"];
133133
// to match the proto2 behavior, LEGACY_REQUIRED is set at the field level
134134
int32 id = 2 [features.field_presence = LEGACY_REQUIRED];
135135
// to match the proto2 behavior, EXPANDED is set at the field level
@@ -169,7 +169,7 @@ package com.example;
169169
170170
message Player {
171171
// in proto3, optional fields have explicit presence
172-
optional string name = 1;
172+
optional string name = 1 [default = "N/A"];
173173
// in proto3 no specified field rule defaults to implicit presence
174174
int32 id = 2;
175175
// in proto3 this is packed by default
@@ -199,7 +199,7 @@ package com.example;
199199
200200
message Player {
201201
// fields have explicit presence, so no explicit setting needed
202-
string name = 1;
202+
string name = 1 [default = "N/A"];
203203
// to match the proto3 behavior, IMPLICIT is set at the field level
204204
int32 id = 2 [features.field_presence = IMPLICIT];
205205
// PACKED is the default state, and is provided just for illustration

content/programming-guides/editions.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ automatically generated class:
376376
<td>Uses variable-length encoding. Inefficient for encoding negative
377377
numbers – if your field is likely to have negative values, use sint32
378378
instead.</td>
379-
<td>int32</td>
379+
<td>int32_t</td>
380380
<td>int</td>
381381
<td>int</td>
382382
<td>int32</td>
@@ -391,7 +391,7 @@ automatically generated class:
391391
<td>Uses variable-length encoding. Inefficient for encoding negative
392392
numbers – if your field is likely to have negative values, use sint64
393393
instead.</td>
394-
<td>int64</td>
394+
<td>int64_t</td>
395395
<td>long</td>
396396
<td>int/long<sup>[4]</sup></td>
397397
<td>int64</td>
@@ -404,7 +404,7 @@ automatically generated class:
404404
<tr>
405405
<td>uint32</td>
406406
<td>Uses variable-length encoding.</td>
407-
<td>uint32</td>
407+
<td>uint32_t</td>
408408
<td>int<sup>[2]</sup></td>
409409
<td>int/long<sup>[4]</sup></td>
410410
<td>uint32</td>
@@ -417,7 +417,7 @@ automatically generated class:
417417
<tr>
418418
<td>uint64</td>
419419
<td>Uses variable-length encoding.</td>
420-
<td>uint64</td>
420+
<td>uint64_t</td>
421421
<td>long<sup>[2]</sup></td>
422422
<td>int/long<sup>[4]</sup></td>
423423
<td>uint64</td>
@@ -431,7 +431,7 @@ automatically generated class:
431431
<td>sint32</td>
432432
<td>Uses variable-length encoding. Signed int value. These more
433433
efficiently encode negative numbers than regular int32s.</td>
434-
<td>int32</td>
434+
<td>int32_t</td>
435435
<td>int</td>
436436
<td>int</td>
437437
<td>int32</td>
@@ -445,7 +445,7 @@ automatically generated class:
445445
<td>sint64</td>
446446
<td>Uses variable-length encoding. Signed int value. These more
447447
efficiently encode negative numbers than regular int64s.</td>
448-
<td>int64</td>
448+
<td>int64_t</td>
449449
<td>long</td>
450450
<td>int/long<sup>[4]</sup></td>
451451
<td>int64</td>
@@ -459,7 +459,7 @@ automatically generated class:
459459
<td>fixed32</td>
460460
<td>Always four bytes. More efficient than uint32 if values are often
461461
greater than 2<sup>28</sup>.</td>
462-
<td>uint32</td>
462+
<td>uint32_t</td>
463463
<td>int<sup>[2]</sup></td>
464464
<td>int/long<sup>[4]</sup></td>
465465
<td>uint32</td>
@@ -473,7 +473,7 @@ automatically generated class:
473473
<td>fixed64</td>
474474
<td>Always eight bytes. More efficient than uint64 if values are often
475475
greater than 2<sup>56</sup>.</td>
476-
<td>uint64</td>
476+
<td>uint64_t</td>
477477
<td>long<sup>[2]</sup></td>
478478
<td>int/long<sup>[4]</sup></td>
479479
<td>uint64</td>
@@ -486,7 +486,7 @@ automatically generated class:
486486
<tr>
487487
<td>sfixed32</td>
488488
<td>Always four bytes.</td>
489-
<td>int32</td>
489+
<td>int32_t</td>
490490
<td>int</td>
491491
<td>int</td>
492492
<td>int32</td>
@@ -499,7 +499,7 @@ automatically generated class:
499499
<tr>
500500
<td>sfixed64</td>
501501
<td>Always eight bytes.</td>
502-
<td>int64</td>
502+
<td>int64_t</td>
503503
<td>long</td>
504504
<td>int/long<sup>[4]</sup></td>
505505
<td>int64</td>
@@ -696,8 +696,8 @@ field default.
696696
You can define aliases by assigning the same value to different enum constants.
697697
To do this you need to set the `allow_alias` option to `true`. Otherwise, the
698698
protocol buffer compiler generates a warning message when aliases are
699-
found. Though all alias values are valid during deserialization, the first value
700-
is always used when serializing.
699+
found. Though all alias values are valid for serialization, only the first value
700+
is used when deserializing.
701701

702702
```proto
703703
enum EnumAllowingAlias {
@@ -716,6 +716,8 @@ enum EnumNotAllowingAlias {
716716
}
717717
```
718718

719+
### Enum Constants {#enum-constants}
720+
719721
Enumerator constants must be in the range of a 32-bit integer. Since `enum`
720722
values use
721723
[varint encoding](/programming-guides/encoding) on the
@@ -725,6 +727,8 @@ these `enum`s can be reused in any message definition in your `.proto` file. You
725727
can also use an `enum` type declared in one message as the type of a field in a
726728
different message, using the syntax `_MessageType_._EnumType_`.
727729

730+
### Language-specific Enum Implementations {#enum-language}
731+
728732
When you run the protocol buffer compiler on a `.proto` that uses an `enum`, the
729733
generated code will have a corresponding `enum` for Java, Kotlin, or C++, or a
730734
special `EnumDescriptor` class for Python that's used to create a set of

content/programming-guides/extension_declarations.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ freshness: { owner: 'shaod' reviewed: '2024-09-16' }
1515
This page describes in detail what extension declarations are, why we need them,
1616
and how we use them.
1717

18-
**NOTE:** Proto3 does not support extensions (except for
18+
{{% alert title="Note" color="note" %}}
19+
Proto3 does not support extensions (except for
1920
[declaring custom options](/programming-guides/proto3/#customoptions)).
20-
Extensions are fully supported in proto2 and editions though.
21+
Extensions are fully supported in proto2 and editions
22+
though.{{% /alert %}}
2123

2224
If you need an introduction to extensions, read this
2325
[extensions guide](https://protobuf.dev/programming-guides/proto2/#extensions)
@@ -74,9 +76,11 @@ This syntax has the following semantics:
7476
(`Foo`) with this name or number, we enforce that the number, type, and full
7577
name of the extension match what is forward-declared here.
7678

77-
**WARNING:** Avoid using declarations for extension range groups such as
78-
`extensions 4, 999`. It is unclear which extension range the declarations apply
79-
to, and it is currently unsupported.
79+
{{% alert title="Warning" color="warning" %}}
80+
Avoid using declarations for extension range groups such as `extensions 4, 999`.
81+
It is unclear which extension range the declarations apply to, and it is
82+
currently
83+
unsupported.{{% /alert %}}
8084

8185
The extension declarations expect two extension fields with different packages:
8286

content/programming-guides/field_presence.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ types (numeric, string, bytes, and enums) which are defined with the `optional`
1919
label have *explicit presence*, like proto2 (this feature is enabled by default
2020
as release 3.15).
2121

22-
**NOTE:** We recommend always adding the `optional` label for proto3 basic
23-
types. This provides a smoother path to editions, which uses explicit presence
24-
by default.
22+
{{% alert title="Note" color="note" %}} We
23+
recommend always adding the `optional` label for proto3 basic types. This
24+
provides a smoother path to editions, which uses explicit presence by
25+
default.{{% /alert %}}
2526

2627
### Presence Disciplines
2728

@@ -214,9 +215,10 @@ For a singular field with numeric, enum, or string type:
214215
- A generated `clear_foo` method must be used to clear (i.e., un-set) the
215216
value.
216217

217-
**Note:** `Has_` methods are not generated for implicit members in most cases.
218-
The exception to this behavior is Dart, which generates `has_` methods with
219-
proto3 proto schema files.
218+
{{% alert title="Note" color="note" %}}
219+
`Has_` methods are not generated for implicit members in most cases. The
220+
exception to this behavior is Dart, which generates `has_` methods with proto3
221+
proto schema files.{{% /alert %}}
220222

221223
### Considerations for Merging
222224

content/programming-guides/proto2.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ automatically generated class:
406406
<td>Uses variable-length encoding. Inefficient for encoding negative
407407
numbers – if your field is likely to have negative values, use sint32
408408
instead.</td>
409-
<td>int32</td>
409+
<td>int32_t</td>
410410
<td>int</td>
411411
<td>int</td>
412412
<td>int32</td>
@@ -421,7 +421,7 @@ automatically generated class:
421421
<td>Uses variable-length encoding. Inefficient for encoding negative
422422
numbers – if your field is likely to have negative values, use sint64
423423
instead.</td>
424-
<td>int64</td>
424+
<td>int64_t</td>
425425
<td>long</td>
426426
<td>int/long<sup>[4]</sup></td>
427427
<td>*int64</td>
@@ -434,7 +434,7 @@ automatically generated class:
434434
<tr>
435435
<td>uint32</td>
436436
<td>Uses variable-length encoding.</td>
437-
<td>uint32</td>
437+
<td>uint32_t</td>
438438
<td>int<sup>[2]</sup></td>
439439
<td>int/long<sup>[4]</sup></td>
440440
<td>*uint32</td>
@@ -447,7 +447,7 @@ automatically generated class:
447447
<tr>
448448
<td>uint64</td>
449449
<td>Uses variable-length encoding.</td>
450-
<td>uint64</td>
450+
<td>uint64_t</td>
451451
<td>long<sup>[2]</sup></td>
452452
<td>int/long<sup>[4]</sup></td>
453453
<td>*uint64</td>
@@ -461,7 +461,7 @@ automatically generated class:
461461
<td>sint32</td>
462462
<td>Uses variable-length encoding. Signed int value. These more
463463
efficiently encode negative numbers than regular int32s.</td>
464-
<td>int32</td>
464+
<td>int32_t</td>
465465
<td>int</td>
466466
<td>int</td>
467467
<td>int32</td>
@@ -475,7 +475,7 @@ automatically generated class:
475475
<td>sint64</td>
476476
<td>Uses variable-length encoding. Signed int value. These more
477477
efficiently encode negative numbers than regular int64s.</td>
478-
<td>int64</td>
478+
<td>int64_t</td>
479479
<td>long</td>
480480
<td>int/long<sup>[4]</sup></td>
481481
<td>*int64</td>
@@ -489,7 +489,7 @@ automatically generated class:
489489
<td>fixed32</td>
490490
<td>Always four bytes. More efficient than uint32 if values are often
491491
greater than 2<sup>28</sup>.</td>
492-
<td>uint32</td>
492+
<td>uint32_t</td>
493493
<td>int<sup>[2]</sup></td>
494494
<td>int/long<sup>[4]</sup></td>
495495
<td>*uint32</td>
@@ -503,7 +503,7 @@ automatically generated class:
503503
<td>fixed64</td>
504504
<td>Always eight bytes. More efficient than uint64 if values are often
505505
greater than 2<sup>56</sup>.</td>
506-
<td>uint64</td>
506+
<td>uint64_t</td>
507507
<td>long<sup>[2]</sup></td>
508508
<td>int/long<sup>[4]</sup></td>
509509
<td>*uint64</td>
@@ -516,7 +516,7 @@ automatically generated class:
516516
<tr>
517517
<td>sfixed32</td>
518518
<td>Always four bytes.</td>
519-
<td>int32</td>
519+
<td>int32_t</td>
520520
<td>int</td>
521521
<td>int</td>
522522
<td>*int32</td>
@@ -529,7 +529,7 @@ automatically generated class:
529529
<tr>
530530
<td>sfixed64</td>
531531
<td>Always eight bytes.</td>
532-
<td>int64</td>
532+
<td>int64_t</td>
533533
<td>long</td>
534534
<td>int/long<sup>[4]</sup></td>
535535
<td>*int64</td>

0 commit comments

Comments
 (0)