Skip to content

Commit 552ce67

Browse files
committed
fix some errors in Documentation.md
1 parent e8f32e5 commit 552ce67

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

Documentation.md

+48-48
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ documentation:
2020
description: Gets a social activity. If the activity does not exist, returns Code.NOT_FOUND.
2121
...
2222
```
23-
如果不同的服务使用了同一个`.proto`文件, 但你希望能为每个服务提供特定的文档,则可用这种添加内部文档的方法。YAML文档注释法允许你在API描述里面添加更加详细的`overview`部分。虽然这样,我们一般更推荐在`.proto`文件中添加文档注释。
23+
如果不同的服务使用了同一个`.proto`文件, 但你希望能为每个服务提供特定的文档,则可用这种添加内部文档的方法。YAML文档注释法允许你在API描述里面添加更加详细的`overview`部分。但是,我们一般更推荐在`.proto`文件中添加文档注释。
2424

2525
`.proto`注释一样,你可以使用Markdown为YAML文件注释提供额外的样式。
2626

2727
## API描述
28-
API描述是一个以动词开头的短语,描述了此API能做什么。 在`.proto`文件中,API描述作为注释添加到相关`service`上去的,例如
28+
API描述是一个以动词开头的短语,描述了此API能做什么。 在`.proto`文件中,API描述作为注释添加到对应`service`上,如下所示
2929

3030
```
3131
// Manages books and shelves in a simple digital library.
@@ -35,11 +35,11 @@ service LibraryService {
3535
```
3636

3737
API描述的其他示例:
38-
* Shares updates, photos, videos, and more with your friends around the world.
39-
* Accesses a cloud-hosted machine learning service that makes it easy to build smart apps that respond to streams of data.
38+
* Shares updates, photos, videos, and more with your friends around the world.
39+
* Accesses a cloud-hosted machine learning service that makes it easy to build smart apps that respond to streams of data.
4040

4141
## 资源描述
42-
资源描述是一个局部句子,说明该资源指的是什么。如果要添加更多信息,请使用额外的句子。在`.proto`文件中,资源描述作为注释添加到对应消息上,例如
42+
资源描述是一个局部句子,说明该资源指的是什么。如果要添加更多信息,请使用额外的句子。在`.proto`文件中,资源描述作为注释添加到对应消息类型上,如下所示
4343
```
4444
// A book resource in the Library API.
4545
message Book {
@@ -48,27 +48,27 @@ message Book {
4848
```
4949

5050
资源描述的其他示例:
51-
* A task on the user's to-do list. Each task has a unique priority.
52-
* An event on the user's calendar.
51+
* A task on the user's to-do list. Each task has a unique priority.
52+
* An event on the user's calendar.
5353

5454
## 字段和参数描述
5555
描述字段或参数的名词短语,一些例子:
5656

57-
* The number of topics in this series.
58-
* The accuracy of the latitude and longitude coordinates, in meters. Must be non-negative.
59-
* Flag governing whether attachment URL values are returned for submission resources in this series. The default value for series.insert is true.
60-
* The container for voting information. Present only when voting information is recorded.
61-
* Not currently used or deprecated.
57+
* The number of topics in this series.
58+
* The accuracy of the latitude and longitude coordinates, in meters. Must be non-negative.
59+
* Flag governing whether attachment URL values are returned for submission resources in this series. The default value for series.insert is true.
60+
* The container for voting information. Present only when voting information is recorded.
61+
* Not currently used or deprecated.
6262

6363
字段和参数描述要遵循以下规则:
6464

65-
* 必须描述清楚边界条件(即要清楚地说明什么是有效的、什么是无效的。谨记开发者是一定会误用你的服务的,且不会阅读底层代码来弄清楚那些不明了的信息。)
66-
* 必须指定所有的默认值或默认行为(即在未提供值的时候服务器会做什么)。
67-
* 当字段或参数是字符串时(例如名称或路径),需要说明其遵循的语法、允许的字符和需要的编码格式。例如:
68-
* 1-255 characters in the set [A-a0-9]
69-
* A valid URL path string starting with / that follows the RFC 2332 conventions. Max length is 500 characters.
70-
* 如果可以的话,给字段或参数提供一个示例值。
71-
* 如果该字段是`必须的``仅输入``仅输出`的,都必须在字段描述的开头说明。默认所有字段和参数都是可选的。例如:
65+
* 必须描述清楚边界条件(即要清楚地说明什么是有效的、什么是无效的。谨记开发者是一定会误用你的服务的,且不会阅读底层代码来弄清楚那些不明了的信息。)
66+
* 必须指定所有的默认值或默认行为(即在未提供值的时候服务器会做什么)。
67+
* 当字段或参数是字符串时(例如名称或路径),需要说明其遵循的语法、允许的字符和需要的编码格式。例如:
68+
* 1-255 characters in the set `[A-a0-9]`
69+
* A valid URL path string starting with / that follows the RFC 2332 conventions. Max length is 500 characters.
70+
* 如果可以的话,给字段或参数提供一个示例值。
71+
* 如果该字段是`Required``Input only``Output only`的,都必须在字段描述的开头说明。默认所有字段和参数都是可选的。例如:
7272

7373
```
7474
message Table {
@@ -87,42 +87,42 @@ message Table {
8787
## 方法描述
8888
方法描述是一个描述方法的作用和方法操作对象的句子。通常以第三人称[现在时的动词](https://developers.google.com/internal/style/reference-verbs)开头(即以's'结尾的动词)。如果需要添加更多详情,则使用其他句子。一些示例:
8989

90-
* Lists calendar events for the authenticated user.
91-
* Updates a calendar event with the data included in the request.
92-
* Deletes a location record from the authenticated user's location history.
93-
* Creates or updates a location record in the authenticated user's location history using the data included in the request. If a location resource already exists with the same timestamp value, the data provided overwrites the existing data.
90+
* Lists calendar events for the authenticated user.
91+
* Updates a calendar event with the data included in the request.
92+
* Deletes a location record from the authenticated user's location history.
93+
* Creates or updates a location record in the authenticated user's location history using the data included in the request. If a location resource already exists with the same timestamp value, the data provided overwrites the existing data.
9494

9595
## 描述的检查清单
96-
你要确保每个描述都是简短但完整的,同时也要可以被那些不太了解你的API的用户看懂。在大多数情况下,不能只是重申显而易见的信息,例如`series.insert`方法的描述不能只是'Inserts a series'。虽然你的命名应该已经表明它是做什么的了,但大多数读者因为想要获取更多详细信息所以要阅读你的描述。如果你不确定描述中要写什么,试着回答以下相关的问题:
97-
98-
* 它是什么?
99-
* 成功时会做什么?失败时会做什么?怎样原因会导致失败?
100-
* 它是幂等的吗?
101-
* 单位是什么?(例如:米、度、像素。)
102-
* 接受值的范围?范围是包含的还是不包含的
103-
* 副作用是什么?
104-
* 如何使用?
105-
* 常见错误是什么?
106-
* 是否会一直存在?(例如: "Container for voting information. Present only when voting information is recorded.")
107-
* 是否有默认设置?
108-
109-
## 惯例
110-
本部分列出了文本描述和文档的一些使用惯例。例如,用'ID'表示标识符(全部大写),而不是'Id'或'id';用'JSON',而不是'Json'或'json'。所有字段/参数使用`code font`格式。字符串要使用引号。
111-
112-
* ID
113-
* JSON
114-
* RPC
115-
* REST
116-
* `property_name``string_literal`
117-
* `true`/`false`
118-
119-
## 要求的级别
96+
你要确保每个描述都是简短但完整的,同时也要可以被那些不太了解你的API的用户看懂。在大多数情况下,不能只是重申显而易见的信息,例如`series.insert`方法的描述不能只是"Inserts a series"。虽然你的命名应该已经表明它是做什么的了,但大多数读者之所以会阅读你的描述是因为他们想要获取更多的详细信息。如果你不确定描述中要写什么,试着回答以下相关的问题:
97+
98+
* 它是什么?
99+
* 成功时会做什么?失败时会做什么?怎样原因会导致失败?
100+
* 它是幂等的吗?
101+
* 单位是什么?(例如:米、度、像素。)
102+
* 接受值的范围?范围是开区间还是闭区间
103+
* 副作用是什么?
104+
* 如何使用?
105+
* 常见错误是什么?
106+
* 是否会一直存在?(例如: "Container for voting information. Present only when voting information is recorded.")
107+
* 是否有默认设置?
108+
109+
## 约定
110+
本部分列出了文本描述和文档的一些使用约定。例如,用'ID'表示标识符(全部大写),而不是'Id'或'id';用'JSON',而不是'Json'或'json'。所有字段/参数使用`code font`格式。字符串要使用引号。
111+
112+
* ID
113+
* JSON
114+
* RPC
115+
* REST
116+
* `property_name``string_literal`
117+
* `true`/`false`
118+
119+
## 要求级别
120120

121121
使用这些术语:must, must not, required, shall, shall not, should, should not, recommended, may, 和 optional来表达预期或要求的级别。
122122

123123
以上词语的含义在[RFC 2119](https://www.ietf.org/rfc/rfc2119.txt)中有定义。您可能想要将RFC摘要里的声明写入你的API文档。
124124

125-
在确定哪个术语符合你的需求的同时也要为开发人员提供灵活性。在API中如果其他选项在技术上也是可行的,就不要使用诸如must的绝对语气
125+
在确定哪个术语符合你的需求的同时也要为开发人员提供灵活性。在API中如果其他选项在技术上也是可行的,就不要使用像must这样绝对的语气
126126

127127
## 语言风格
128128
[命名约定](Naming_Conventions.md)一样,在写注释时建议使用简单一致的词汇和风格,让非英语母语的读者容易理解。因此要避免使用行话、俚语、复杂的隐喻、流行文化或其他不容易理解的内容。使用友好专业的风格,并尽可能保持注释的简洁。请记住,大部分读者只想知道如何使用API,而不是阅读你的文档!

0 commit comments

Comments
 (0)