Skip to content

Commit dcc3d66

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This CL contains primarily changes to the structure of the C++ API docs to get them to render correctly (#27).
Also included are: * changes to the overview topic to provide information about field name requirements * a news article announcing support changes for versions of Bazel * updates to the guidance in the Dos and Don'ts topic about using text formats * a correction in the Encoding topic for i64 in the wire format (#61) * new content in the Enumerations section of the proto2 topic to cover how default values are different when a non-zero-value default is specified * an update to the textformat spec topic about the default file extension (`.txtpb`) * a correction to the Ruby section of the Version Support topic. PiperOrigin-RevId: 549084180 Change-Id: I22df55da724e4756e67bdce68e56990f6e8ff7c3
1 parent 842a4ba commit dcc3d66

File tree

53 files changed

+757
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+757
-395
lines changed

content/news/2023-07-17.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
+++
2+
title = "Changes Announced on July 17, 2023"
3+
weight = 21
4+
linkTitle = "July 17, 2023"
5+
toc_hide = "true"
6+
description = "Changes announced for Protocol Buffers on July 17, 2023."
7+
type = "docs"
8+
+++
9+
10+
## Dropping Bazel 5.x Support
11+
12+
As per our official
13+
[support policy](https://opensource.google/documentation/policies/cplusplus-support),
14+
we will be dropping support for Bazel 5.x and lower. This means the minimum
15+
supported Bazel version is 6.2.x.

content/news/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ type = "docs"
88
News topics provide information about past events and changes with Protocol
99
Buffers, and plans for upcoming changes.
1010

11+
* [July 17, 2023](/news/2023-07-17) - Dropping support
12+
for older versions of Bazel
1113
* [July 6, 2023](/news/2023-07-06) - Dropping support
1214
for older versions of PHP, Ruby, and Python
1315
* [June 29, 2023](/news/2023-06-29) - Protobuf Editions

content/overview.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,19 @@ message, itself. For example, the protobuf library's internal message schema
262262
allows extensions for custom, usage-specific options.
263263
264264
For more information about the options available, see the language guide for
265-
[proto2](/programming-guides/proto) or
265+
[proto2](/programming-guides/proto2) or
266266
[proto3](/programming-guides/proto3).
267267
268-
After setting optionality and field type, you assign a field number. Field
268+
After setting optionality and field type, you choose a name for the field.
269+
There are some things to keep in mind when setting field names:
270+
271+
* It can sometimes be difficult, or even impossible, to change field names
272+
after they've been used in production.
273+
* Field names cannot contain dashes. For more on field name syntax, see
274+
[Message and Field Names](/programming-guides/style#message-field-names).
275+
* Use pluralized names for repeated fields.
276+
277+
After assigning a name to the field, you assign a field number. Field
269278
numbers cannot be repurposed or reused. If you delete a field, you should
270279
reserve its field number to prevent someone from accidentally reusing the
271280
number.

content/programming-guides/dos-donts.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,17 @@ For example:
171171
https://google.github.io/styleguide/cppguide.html#Namespace_Names.
172172
If these style guides conflict, use `java_package` for Java.
173173

174-
## **Never** Use Text-format Messages for Interchange
174+
## **Don't** use Text Format Messages for Interchange
175175

176-
Deserializing of text-format protocol buffers will fail when the binary is
177-
unaware of a field rename, a new field, or a new extension. In general,
178-
text-format is not future proof. Use text-format for human editing and debugging
179-
only.
176+
Text-based serialization formats like text format and
177+
JSON represent fields and enum values as strings. As a result, deserialization
178+
of protocol buffers in these formats using old code will fail when a field or
179+
enum value is renamed, or when a new field or enum value or extension is added.
180+
Use binary serialization when possible for data interchange, and use text format
181+
for human editing and debugging only.
182+
183+
If you use protos converted to JSON in your API or for storing data, you may not
184+
be able to safely rename fields or enums at all.
180185

181186
## **Never** Rely on Serialization Stability Across Builds
182187

content/programming-guides/encoding.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ Field numbers may be declared in any order in a `.proto` file. The order chosen
483483
has no effect on how the messages are serialized.
484484

485485
When a message is serialized, there is no guaranteed order for how its known or
486-
[unknown fields](/programming-guides/proto#updating) will
487-
be written. Serialization order is an implementation detail, and the details of
488-
any particular implementation may change in the future. Therefore, protocol
489-
buffer parsers must be able to parse fields in any order.
486+
[unknown fields](/programming-guides/proto2#updating)
487+
will be written. Serialization order is an implementation detail, and the
488+
details of any particular implementation may change in the future. Therefore,
489+
protocol buffer parsers must be able to parse fields in any order.
490490

491491
### Implications {#implications}
492492

@@ -541,7 +541,7 @@ i32 := sfixed32 | fixed32 | float;
541541
memcpy of the equivalent C types (u?int32_t, float)
542542
i64 := sfixed64 | fixed64 | double;
543543
encoded as 8-byte little-endian;
544-
memcpy of the equivalent C types (u?int32_t, float)
544+
memcpy of the equivalent C types (u?int64_t, double)
545545
546546
len-prefix := size (message | string | bytes | packed);
547547
size encoded as int32 varint

content/programming-guides/proto2.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,14 @@ message SearchRequest {
599599
optional int32 result_per_page = 3 [default = 10];
600600
optional Corpus corpus = 4 [default = CORPUS_UNIVERSAL];
601601
}
602-
603602
```
604603

604+
Because `SearchRequest` sets a default for the value of the `corpus` field, the
605+
`CORPUS_UNSPECIFIED` value will not be used as a default. It will still be used
606+
if a value of 0 is encountered on the wire. Other instances of the `Corpus` type
607+
that **don't** set a default would use the `CORPUS_UNSPECIFIED` value as the
608+
default.
609+
605610
You can define aliases by assigning the same value to different enum constants.
606611
To do this you need to set the `allow_alias` option to `true`. Otherwise, the
607612
protocol buffer compiler generates a warning message when aliases are

0 commit comments

Comments
 (0)