Skip to content

Commit d6d3c2d

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 495640776 Change-Id: Ia351415c00b41c89f47ee27592156c0f5930b5a4
1 parent da6b4d3 commit d6d3c2d

File tree

158 files changed

+122345
-42
lines changed

Some content is hidden

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

158 files changed

+122345
-42
lines changed

.github/workflows/gh-pages.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
uses: peaceiris/actions-hugo@v2
2020
with:
2121
hugo-version: 'latest'
22-
# extended: true
22+
extended: true
23+
24+
- name: Install Dependencies
25+
run: npm install autoprefixer postcss postcss-cli
2326

2427
- name: Build
2528
run: hugo --minify
@@ -29,4 +32,5 @@ jobs:
2932
if: github.ref == 'refs/heads/main'
3033
with:
3134
github_token: ${{ secrets.GITHUB_TOKEN }}
32-
publish_dir: ./public
35+
publish_dir: ./public
36+
cname: protobuf.dev

config.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# baseURL = 'https://protobuf.dev'
1+
baseURL = 'https://protobuf.dev'
22
languageCode = 'en-us'
33
title = 'Protocol Buffers Documentation'
44
sidebar_search_disable = true
@@ -119,9 +119,6 @@ github_repo = "https://github.com/protocolbuffers/protocolbuffers.github.io"
119119
# An optional link to a related project repo. For example, the sibling repository where your product code lives.
120120
github_project_repo = "https://github.com/protocolbuffers/protobuf"
121121

122-
# Specify a value here if your content directory is not in your repo's root directory
123-
github_subdir = "/docs"
124-
125122
# Uncomment this if you have a newer GitHub repo with "main" as the default branch,
126123
# or specify a new value if you want to reference another branch in your GitHub links
127124
# github_branch= "main"
@@ -145,7 +142,7 @@ breadcrumb_disable = false
145142
# Set to true to disable the About link in the site footer
146143
footer_about_disable = false
147144
# Set to false if you don't want to display a logo (/assets/icons/logo.svg) in the top navbar
148-
navbar_logo = true
145+
navbar_logo = false
149146
# Set to true if you don't want the top navbar to be translucent when over a `block/cover`, like on the homepage.
150147
navbar_translucent_over_cover_disable = false
151148
# Enable to show the side bar menu in its compact state.
@@ -191,4 +188,4 @@ enable = false
191188
name = "Developer mailing list"
192189
url = "https://groups.google.com/g/protobuf"
193190
icon = "fa fa-envelope"
194-
desc = "Discuss development issues around the project"
191+
desc = "Discuss development issues around the project"

content/programming-guides/dos-donts.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ zero and can round-trip (deserialize, serialize) an unknown enum value.
7070
[example-unspecified]: http://cs/#search/&q=file:proto%20%22_UNSPECIFIED%20=%200%22&type=cs
7171
[proto-enums]: /programming-guides/proto#enum
7272

73+
## **Don't** Use C/C++ Macro Constants for Enum Values
74+
75+
Using words that have already been defined by the C++ language - specifically,
76+
in its headers such as `math.h`, may cause compilation errors if the `#include`
77+
statement for one of those headers appears before the one for `.proto.h`. Avoid
78+
using macro constants such as "`NULL`," "`NAN`," and "`DOMAIN`" as enum values.
79+
7380
## **Do** Use Well-Known Types and Common Types
7481

7582
Embedding the following common, shared types is strongly encouraged. Do not use
@@ -151,18 +158,6 @@ Going from scalar to repeated is OK in proto2 and in proto3 with
151158
`[packed=false]` because for binary serialization the scalar value becomes a
152159
one-element list .
153160

154-
## **Always** Create a Build Rule for Your Proto Files
155-
156-
If your proto is only used by a script that doesn't require a build rule, create
157-
a `proto_library` rule with an associated
158-
`build_test` rule.
159-
160-
With a `build_test` rule, errors in the file are caught when the test fails.
161-
Otherwise, typos and errors can persist and lead to hard-to-diagnose
162-
problems. Adding this `build_test` to
163-
your build script is also highly recommended, so you
164-
can be notified of future breakages.
165-
166161
## **Do** Follow the Style Guide for Generated Code
167162

168163
Proto generated code is referred to in normal code. Ensure that options in

content/programming-guides/proto.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,14 @@ the following rules:
829829
recognized and newly-added values, which means that order will not be
830830
preserved.
831831
* Changing a single `optional` field or extension into a member of a **new**
832-
`oneof` is safe and binary compatible. Moving multiple `optional` fields
833-
into a new `oneof` may be safe if you are sure that no code sets more than
834-
one at a time. Moving any fields into an existing `oneof` is not safe.
835-
Likewise, changing a single field `oneof` to an `optional` field or
836-
extension is safe.
832+
`oneof` is binary compatible, however for some languages (notably, Go) the
833+
generated code's API will change in incompatible ways. For this reason,
834+
Google does not make such changes in its public APIs, as documented in
835+
[AIP-180](https://google.aip.dev/180#moving-into-oneofs). With
836+
the same caveat about source-compatibility, moving multiple fields into a
837+
new `oneof` may be safe if you are sure that no code sets more than one at a
838+
time. Moving fields into an existing `oneof` is not safe. Likewise, changing
839+
a single field `oneof` to an `optional` field or extension is safe.
837840
* Changing a field between a `map<K, V>` and the corresponding `repeated`
838841
message field is binary compatible (see [Maps](#maps), below, for the
839842
message layout and other restrictions). However, the safety of the change is
@@ -1082,7 +1085,7 @@ wire is a member of the oneof.
10821085
information (some fields will be cleared) after the message is serialized
10831086
and parsed. However, you can safely move a single field into a **new** oneof
10841087
and may be able to move multiple fields if it is known that only one is ever
1085-
set.
1088+
set. See [Updating A Message Type](#updating) for further details.
10861089
* **Delete a oneof field and add it back**: This may clear your currently set
10871090
oneof field after the message is serialized and parsed.
10881091
* **Split or merge oneof**: This has similar issues to moving regular
@@ -1442,8 +1445,9 @@ Here are a few of the most commonly used options:
14421445
14431446
* `deprecated` (field option): If set to `true`, indicates that the field is
14441447
deprecated and should not be used by new code. In most languages this has no
1445-
actual effect. In Java, this becomes a `@Deprecated` annotation. In the
1446-
future, other language-specific code generators may generate deprecation
1448+
actual effect. In Java, this becomes a `@Deprecated` annotation. For C++,
1449+
clang-tidy will generate warnings whenever deprecated fields are used. In
1450+
the future, other language-specific code generators may generate deprecation
14471451
annotations on the field's accessors, which will in turn cause a warning to
14481452
be emitted when compiling code which attempts to use the field. If the field
14491453
is not used by anyone and you want to prevent new users from using it,

content/programming-guides/proto3.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -948,10 +948,14 @@ following rules:
948948
deserialized is language-dependent. Int fields always just preserve their
949949
value.
950950
* Changing a single `optional` field or extension into a member of a **new**
951-
`oneof` is safe and binary compatible. Moving multiple fields into a new
952-
`oneof` may be safe if you are sure that no code sets more than one at a
953-
time. Moving any fields into an existing `oneof` is not safe. Likewise,
954-
changing a single field `oneof` to an `optional` field or extension is safe.
951+
`oneof` is binary compatible, however for some languages (notably, Go) the
952+
generated code's API will change in incompatible ways. For this reason,
953+
Google does not make such changes in its public APIs, as documented in
954+
[AIP-180](https://google.aip.dev/180#moving-into-oneofs). With
955+
the same caveat about source-compatibility, moving multiple fields into a
956+
new `oneof` may be safe if you are sure that no code sets more than one at a
957+
time. Moving fields into an existing `oneof` is not safe. Likewise, changing
958+
a single field `oneof` to an `optional` field or extension is safe.
955959

956960
## Unknown Fields {#unknowns}
957961

@@ -1116,7 +1120,7 @@ wire is a member of the oneof.
11161120
information (some fields will be cleared) after the message is serialized
11171121
and parsed. However, you can safely move a single field into a **new** oneof
11181122
and may be able to move multiple fields if it is known that only one is ever
1119-
set.
1123+
set. See [Updating A Message Type](#updating) for further details.
11201124
* **Delete a oneof field and add it back**: This may clear your currently set
11211125
oneof field after the message is serialized and parsed.
11221126
* **Split or merge oneof**: This has similar issues to moving regular fields.
@@ -1263,12 +1267,19 @@ Proto3 supports a canonical encoding in JSON, making it easier to share data
12631267
between systems. The encoding is described on a type-by-type basis in the table
12641268
below.
12651269

1266-
If a value is missing in the JSON-encoded data or if its value is `null`, it
1267-
will be interpreted as the appropriate [default value](#default) when parsed
1268-
into a protocol buffer. If a field has the default value in the protocol buffer,
1269-
it will be omitted in the JSON-encoded data by default to save space. An
1270-
implementation may provide options to emit fields with default values in the
1271-
JSON-encoded output.
1270+
When parsing JSON-encoded data into a protocol buffer, if a value is missing or
1271+
if its value is `null`, it will be interpreted as the corresponding
1272+
[default value](#default).
1273+
1274+
When generating JSON-encoded output from a protocol buffer, if a protobuf field
1275+
has the default value and if the field doesn't support field presence, it will
1276+
be omitted from the output by default. An implementation may provide options to
1277+
include fields with default values in the output.
1278+
1279+
A proto3 field that is defined with the `optional` keyword supports field
1280+
presence. Fields that have a value set and that support field presence always
1281+
include the field value in the JSON-encoded output, even if it is the default
1282+
value.
12721283

12731284
<table>
12741285
<tbody>
@@ -1557,8 +1568,9 @@ Here are a few of the most commonly used options:
15571568
15581569
* `deprecated` (field option): If set to `true`, indicates that the field is
15591570
deprecated and should not be used by new code. In most languages this has no
1560-
actual effect. In Java, this becomes a `@Deprecated` annotation. In the
1561-
future, other language-specific code generators may generate deprecation
1571+
actual effect. In Java, this becomes a `@Deprecated` annotation. For C++,
1572+
clang-tidy will generate warnings whenever deprecated fields are used. In
1573+
the future, other language-specific code generators may generate deprecation
15621574
annotations on the field's accessors, which will in turn cause a warning to
15631575
be emitted when compiling code which attempts to use the field. If the field
15641576
is not used by anyone and you want to prevent new users from using it,

content/reference/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ details, see [Other Languages](/reference/other).
4242

4343
- [Go Generated Code Guide](/reference/go/go-generated)
4444
- [Go API (godoc)](https://pkg.go.dev/google.golang.org/protobuf/proto)
45+
4546
- [Go FAQ](/reference/go/faq)
4647

4748
### Java Reference
@@ -61,6 +62,7 @@ details, see [Other Languages](/reference/other).
6162
### PHP Reference
6263

6364
- [PHP Generated Code Guide](/reference/php/php-generated)
65+
- [PHP API](/reference/php/api-docs)
6466

6567
### Python Reference
6668

content/reference/cpp/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ description: "This section contains reference documentation for working with pro
1212
* [C++ Generated Code Guide](/reference/cpp/cpp-generated)
1313
* [C++ Arena Allocation Guide](/reference/cpp/arenas)
1414

15-
* [C++ API](/reference/cpp)
15+
* [C++ API](/reference/cpp/api-docs)

content/reference/php/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ description: "This section contains reference documentation for working with pro
1010

1111

1212
* [PHP Generated Code Guide](/reference/php/php-generated)
13+
* [PHP API](/reference/php/api-docs)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- mdformat global-off -->
2+
3+
---
4+
title: "PHP API"
5+
manualLink: "/reference/php/api-docs/"
6+
manualLinkTarget: "_blank"
7+
weight: 530
8+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.5.1

0 commit comments

Comments
 (0)