Skip to content

Commit b991947

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This change includes the following:
* Adds clarifying information about the scope of features to /editions/features.md * Adds information about Proto Python being able to generate `.pyi` files in /getting-started/pythontutorial.md * Changes wording in /overview.md regarding the components that make up protocol buffers * Adds information about how `java_package` and `java_alt_api_package` options are interpreted to /reference/java/java-proto-names.md * Adds a new topic, /reference/protobuf/edition-2023-spec.md * Updates /support/version-support.md to reflect the end of support for 3.21.x in C++ PiperOrigin-RevId: 622020800 Change-Id: Ia9a06a1fadfb6c138ea8828fc1537d42ea7ca604
1 parent 57de98d commit b991947

File tree

6 files changed

+476
-13
lines changed

6 files changed

+476
-13
lines changed

content/editions/features.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ act like proto2 or proto3 files. For more information on how Editions and
2424
Features work together to set behavior, see
2525
[Protobuf Editions Overview](/editions/overview).
2626

27+
Each of the following sections has an entry for what scope the feature applies
28+
to. This can include file, enum, message, or field. The following sample shows a
29+
mock feature applied to each scope:
30+
31+
```proto
32+
edition = "2023";
33+
34+
// File-scope definition
35+
option features.bar = BAZ;
36+
37+
enum Foo {
38+
// Enum-scope definition
39+
option features.bar = QUX;
40+
41+
A = 1;
42+
B = 2;
43+
}
44+
45+
message Corge {
46+
// Message-scope definition
47+
option features.bar = QUUX;
48+
49+
// Field-scope definition
50+
Foo A = 1 [features.bar = GRAULT];
51+
}
52+
```
53+
54+
In this example, the setting `GRAULT` in the field-scope feature definition
55+
overrides the message-scope QUUX setting.
56+
2757
### `features.enum_type` {#enum_type}
2858

2959
This feature sets the behavior for how enum values that aren't contained within
@@ -38,7 +68,7 @@ and after of a proto3 file.
3868
unknown field set.
3969
* `OPEN:` Open enums parse out of range values into their fields directly.
4070

41-
**Applicable to the following elements:** File, Enum
71+
**Applicable to the following scopes:** File, Enum
4272

4373
**Default behavior in Edition 2023:** `OPEN`
4474

@@ -90,7 +120,7 @@ whether a protobuf field has a value.
90120
serialized onto the wire (even if it is explicitly set). `has_*` functions
91121
are not generated for fields set to `IMPLICIT`.
92122

93-
**Applicable to the following elements:** File, Field
123+
**Applicable to the following scopes:** File, Field
94124

95125
**Default value in the Edition 2023:** `EXPLICIT`
96126

@@ -169,7 +199,7 @@ and after of a proto3 file. Editions behavior matches the behavior in proto3.
169199
JSON. Certain protos are allowed that can result in unspecified behavior at
170200
runtime (such as many:1 or 1:many mappings).
171201

172-
**Applicable to the following elements:** File, Message, Enum
202+
**Applicable to the following scopes:** File, Message, Enum
173203

174204
**Default behavior in Edition 2023:** `ALLOW`
175205

@@ -215,7 +245,7 @@ and after of a proto3 file.
215245
* `DELIMITED`: Message-typed fields are encoded as
216246
[groups](/programming-guides/proto2#groups).
217247

218-
**Applicable to the following elements:** File, Field
248+
**Applicable to the following scopes:** File, Field
219249

220250
**Default behavior in Edition 2023:** `LENGTH_PREFIXED`
221251

@@ -264,7 +294,7 @@ for `repeated` fields has been migrated to in Editions.
264294
* `EXPANDED`: `Repeated` fields are each encoded with the field number for
265295
each value.
266296

267-
**Applicable to the following elements:** File, Field
297+
**Applicable to the following scopes:** File, Field
268298

269299
**Default behavior in Edition 2023:** `PACKED`
270300

@@ -335,7 +365,7 @@ and after of a proto3 file.
335365
Parsers may handle this type of field in an unpredictable way, such as
336366
replacing invalid characters. This is the default proto2 behavior.
337367

338-
**Applicable to the following elements:** File, Field
368+
**Applicable to the following scopes:** File, Field
339369

340370
**Default behavior in Edition 2023:** `VERIFY`
341371

@@ -387,7 +417,7 @@ before and after of a proto3 file.
387417
* `true`: Treats the enum as closed regardless of [`enum_type`](#enum_type).
388418
* `false`: Respect whatever is set in the `enum_type`.
389419

390-
**Applicable to the following elements:** File, Field
420+
**Applicable to the following scopes:** File, Field
391421

392422
**Default behavior in Edition 2023:** `false`
393423

@@ -442,7 +472,7 @@ before and after of a proto3 file.
442472
* `VERIFY`: Overrides the file-level `features.utf8_validation` setting to
443473
force it to `VERIFY` for Java only.
444474

445-
**Applicable to the following elements:** Field, File
475+
**Applicable to the following scopes:** Field, File
446476

447477
**Default behavior in Edition 2023:** `DEFAULT`
448478

content/getting-started/pythontutorial.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ compiler `protoc` on your `.proto`:
195195
Because you want Python classes, you use the `--python_out` option --
196196
similar options are provided for other supported languages.
197197

198-
This generates `addressbook_pb2.py` in your specified destination directory.
198+
Protoc is also able to generate python stubs (`.pyi`) with `--pyi_out`.
199+
200+
This generates `addressbook_pb2.py` (or `addressbook_pb2.pyi`) in your specified
201+
destination directory.
199202

200203
## The Protocol Buffer API {#protobuf-api}
201204

content/overview.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ of data streams and using a variety of languages.
1313

1414
Protocol buffers are a combination of the definition language (created in
1515
`.proto` files), the code that the proto compiler generates to interface with
16-
data, language-specific runtime libraries, and the serialization format for data
17-
that is written to a file (or sent across a network connection).
16+
data, language-specific runtime libraries, the serialization format for data
17+
that is written to a file (or sent across a network connection), and the
18+
serialized data.
1819

1920
## What Problems do Protocol Buffers Solve? {#solve}
2021

content/reference/java/java-proto-names.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ This document contains information on what the fully-qualified Java name of a
1010
proto is, based on the different proto options. This name corresponds to the
1111
package you need to import to use that message.
1212

13+
**NOTE:** The `java_package` and `java_alt_api_package` options are interpreted
14+
relative to the API indicated by `java_api_version`. For example, if
15+
`java_api_version` is 1, then the proto1 package will be `java_package` and the
16+
proto2 package (the "alternative" API) will be `java_alt_api_package`. And if
17+
`java_api_version` is 2, then `java_package` determines the proto2 package and
18+
`java_alt_api_package` determines the proto1 package.
19+
1320
## Immutable API Message Names { #immutable-api-message-names }
1421

1522
The names for protos generated by the immutable API (`java_proto_library` BUILD

0 commit comments

Comments
 (0)