Skip to content

Commit 74c97c5

Browse files
authored
Merge pull request #45435 from windsonsea/guidey
[zh] Sync style/style-guide.md
2 parents a053579 + 8fbba15 commit 74c97c5

File tree

1 file changed

+89
-41
lines changed

1 file changed

+89
-41
lines changed

content/zh-cn/docs/contribute/style/style-guide.md

Lines changed: 89 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,28 @@ The copy is called a "fork". | The copy is called a "fork."
239239
<!--
240240
## Inline code formatting
241241
242-
### Use code style for inline code, commands, and API objects {#code-style-inline-code}
242+
### Use code style for inline code, commands {#code-style-inline-code}
243243
244244
For inline code in an HTML document, use the `<code>` tag. In a Markdown
245-
document, use the backtick (`` ` ``).
245+
document, use the backtick (`` ` ``). However, API kinds such as StatefulSet
246+
or ConfigMap are written verbatim (no backticks); this allows using possessive
247+
apostrophes.
246248
-->
247249
## 行间代码格式 {#inline-code-formatting}
248250

249-
### 为行间代码、命令与 API 对象使用代码样式 {#code-style-inline-code}
251+
### 为行间代码、命令使用代码样式 {#code-style-inline-code}
250252

251-
对于 HTML 文档中的行间代码,使用 `<code>` 标记。
252-
在 Markdown 文档中,使用反引号(`` ` ``
253+
对于 HTML 文档中的行间代码,使用 `<code>` 标记。在 Markdown 文档中,使用反引号(`` ` ``)。
254+
然而,StatefulSet 或 ConfigMap 这些 API 类别是直接书写的(不用反引号);这样允许使用表示所有格的撇号
253255

254256
<!--
255-
{{< table caption = "Do and Don't - Use code style for inline code, commands and API objects" >}}
257+
{{< table caption = "Do and Don't - Use code style for inline code, commands, and API objects" >}}
256258
Do | Don't
257259
:--| :-----
258-
The `kubectl run` command creates a `Pod`. | The "kubectl run" command creates a pod.
259-
The kubelet on each node acquires a `Lease`… | The kubelet on each node acquires a lease…
260-
A `PersistentVolume` represents durable storage… | A Persistent Volume represents durable storage…
260+
The `kubectl run` command creates a Pod. | The "kubectl run" command creates a Pod.
261+
The kubelet on each node acquires a Lease… | The kubelet on each node acquires a `Lease`…
262+
A PersistentVolume represents durable storage… | A `PersistentVolume` represents durable storage…
263+
The CustomResourceDefinition's `.spec.group` field… | The `CustomResourceDefinition.spec.group` field…
261264
For declarative management, use `kubectl apply`. | For declarative management, use "kubectl apply".
262265
Enclose code samples with triple backticks. (\`\`\`)| Enclose code samples with any other syntax.
263266
Use single backticks to enclose inline code. For example, `var example = true`. | Use two asterisks (`**`) or an underscore (`_`) to enclose inline code. For example, **var example = true**.
@@ -269,9 +272,10 @@ Remove trailing spaces in the code. | Add trailing spaces in the code, where the
269272
{{< table caption = "行间代码、命令和 API 对象约定" >}}
270273
可以 | 不可以
271274
:--| :-----
272-
`kubectl run` 命令会创建一个 `Pod` | "kubectl run" 命令会创建一个 Pod。
273-
每个节点上的 kubelet 都会获得一个 `Lease` | 每个节点上的 kubelet 都会获得一个 lease…
274-
一个 `PersistentVolume` 代表持久存储 | 一个 Persistent Volume 代表持久存储…
275+
`kubectl run` 命令会创建一个 Pod。 | "kubectl run" 命令会创建一个 Pod。
276+
每个节点上的 kubelet 都会获得一个 Lease… | 每个节点上的 kubelet 都会获得一个 `Lease`
277+
一个 PersistentVolume 代表持久存储… | 一个 `PersistentVolume` 代表持久存储…
278+
CustomResourceDefinition 的 `.spec.group` 字段… | `CustomResourceDefinition.spec.group` 字段…
275279
在声明式管理中,使用 `kubectl apply`。 | 在声明式管理中,使用 "kubectl apply"。
276280
用三个反引号来(\`\`\`)标示代码示例 | 用其他语法来标示代码示例。
277281
使用单个反引号来标示行间代码。例如:`var example = true`。 | 使用两个星号(`**`)或者一个下划线(`_`)来标示行间代码。例如:**var example = true**
@@ -395,62 +399,109 @@ Set the value of the `replicas` field to 2. | Set the value of the `replicas` fi
395399
`replicas` 字段值设置为 2。 | 将 `replicas` 字段值设置为 `2`
396400
{{< /table >}}
397401

402+
<!--
403+
However, consider quoting values where there is a risk that readers might confuse the value
404+
with an API kind.
405+
-->
406+
然而,在读者可能会将某些值与 API 类别混淆时,请考虑为这些值添加引号。
407+
398408
<!--
399409
## Referring to Kubernetes API resources
400410
401411
This section talks about how we reference API resources in the documentation.
402412
403413
### Clarification about "resource"
404414
405-
Kubernetes uses the word "resource" to refer to API resources, such as `pod`,
406-
`deployment`, and so on. We also use "resource" to talk about CPU and memory
407-
requests and limits. Always refer to API resources as "API resources" to avoid
408-
confusion with CPU and memory resources.
415+
Kubernetes uses the word _resource_ to refer to API resources. For example,
416+
the URL path `/apis/apps/v1/namespaces/default/deployments/my-app` represents a
417+
Deployment named "my-app" in the "default"
418+
{{< glossary_tooltip text="namespace" term_id="namespace" >}}. In HTTP jargon,
419+
{{< glossary_tooltip text="namespace" term_id="namespace" >}} is a resource -
420+
the same way that all web URLs identify a resource.
409421
-->
410422
## 引用 Kubernetes API 资源 {#referring-to-kubernetes-api-resources}
411423

412424
本节讨论我们如何在文档中引用 API 资源。
413425

414426
### 有关 “资源” 的阐述
415427

416-
Kubernetes 使用 “resource” 一词来指代 API 资源,例如 `pod``deployment` 等。
417-
我们还使用 “resource” 来谈论 CPU 和内存请求和限制。
418-
所以始终将 API 资源称为 “API resources” 以避免与 CPU 和内存资源混淆。
428+
Kubernetes 使用单词 _resource_ 一词来指代 API 资源。
429+
例如,URL 路径 `/apis/apps/v1/namespaces/default/deployments/my-app` 表示 "default"
430+
{{< glossary_tooltip text="名字空间" term_id="namespace" >}}中名为 "my-app" 的 Deployment。
431+
在 HTTP 的术语中,{{< glossary_tooltip text="名字空间" term_id="namespace" >}}是一个资源,
432+
就像所有 Web URL 都标识一个资源。
433+
434+
<!--
435+
Kubernetes documentation also uses "resource" to talk about CPU and memory
436+
requests and limits. It's very often a good idea to refer to API resources
437+
as "API resources"; that helps to avoid confusion with CPU and memory resources,
438+
or with other kinds of resource.
439+
-->
440+
Kubernetes 文档在讨论 CPU 和内存请求以及限制也使用“资源(resource)”一词。
441+
将 API 资源称为 "API 资源" 往往是一个好的做法;这有助于避免与 CPU 和内存资源或其他类别的资源混淆。
442+
443+
<!--
444+
If you are using the lowercase plural form of a resource name, such as
445+
`deployments` or `configmaps`, provide extra written context to help readers
446+
understand what you mean. If you are using the term in a context where the
447+
UpperCamelCase name could work too, and there is a risk of ambiguity,
448+
consider using the API kind in UpperCamelCase.
449+
-->
450+
如果你使用资源名称的小写复数形式,例如 `deployments``configmaps`
451+
请提供额外的书面上下文来帮助读者理解你的用意。
452+
如果你使用术语时所处的上下文中使用驼峰编码(UpperCamelCase)的名称也可行,且术语存在歧义的风险,
453+
应该考虑使用 UpperCamelCase 形式的 API 类别。
419454

420455
<!--
421456
### When to use Kubernetes API terminologies
422457
423458
The different Kubernetes API terminologies are:
424459
425-
- Resource type: the name used in the API URL (such as `pods`, `namespaces`)
426-
- Resource: a single instance of a resource type (such as `pod`, `secret`)
427-
- Object: a resource that serves as a "record of intent". An object is a desired
460+
- _API kinds_: the name used in the API URL (such as `pods`, `namespaces`).
461+
API kinds are sometimes also called _resource types_.
462+
- _API resource_: a single instance of an API kind (such as `pod`, `secret`).
463+
- _Object_: a resource that serves as a "record of intent". An object is a desired
428464
state for a specific part of your cluster, which the Kubernetes control plane tries to maintain.
429-
430-
Always use "resource" or "object" when referring to an API resource in docs.
431-
For example, use "a `Secret` object" over just "a `Secret`".
465+
All objects in the Kubernetes API are also resources.
432466
-->
433467
### 何时使用 Kubernetes API 术语
434468

435469
不同 Kubernetes API 术语的说明如下:
436470

437-
- 资源类型:API URL 中使用的名称(如 `pods``namespaces`
438-
- 资源:资源类型的单个实例(如 `pod``secret`
439-
- 对象:作为 “意向记录” 的资源。对象是集群特定部分的期望状态,
471+
- **API 类别** :API URL 中使用的名称(如 `pods``namespaces`)。
472+
API 类别有时也称为 **资源类型**
473+
- **API 资源** :API 类别的单个实例(如 `pod``secret`
474+
- **对象** :作为 “意向记录” 的资源。对象是集群特定部分的期望状态,
440475
该状态由 Kubernetes 控制平面负责维护。
476+
Kubernetes API 中的所有对象也都是资源。
441477

442-
在文档中引用 API 资源时始终使用 “资源” 或 “对象”。
443-
例如,使用 “一个 `Secret` 对象” 而不是 “一个 `Secret`”。
478+
<!--
479+
For clarity, you can add "resource" or "object" when referring to an API resource in Kubernetes
480+
documentation.
481+
An example: write "a Secret object" instead of "a Secret".
482+
If it is clear just from the capitalization, you don't need to add the extra word.
483+
484+
Consider rephrasing when that change helps avoid misunderstandings. A common situation is
485+
when you want to start a sentence with an API kind, such as “Secret”; because English
486+
and other languages capitalize at the start of sentences, readers cannot tell whether you
487+
mean the API kind or the general concept. Rewording can help.
488+
-->
489+
为了清晰起见,在 Kubernetes 文档中引用 API 资源时可以使用 "资源" 或 "对象"。
490+
例如:写成 "Secret 对象" 而不是 "Secret"。
491+
如果仅大写就能明确含义,那么无需添加额外的单词。
492+
493+
当修改有助于避免误解时,那就考虑修改表述。
494+
一个常见的情况是当你想要某个句子以 "Secret" 这种 API 类别开头时;
495+
因为英语和其他几种语言会对句首的第一个字母大写,所以读者无法确定你说的是 API 类别还是一般概念。
496+
此时重新构词有助于让句子更清晰。
444497

445498
<!--
446499
### API resource names
447500
448501
Always format API resource names using [UpperCamelCase](https://en.wikipedia.org/wiki/Camel_case),
449-
also known as PascalCase, and code formatting.
450-
451-
For inline code in an HTML document, use the `<code>` tag. In a Markdown document, use the backtick (`` ` ``).
502+
also known as PascalCase. Do not write API kinds with code formatting.
452503
453-
Don't split an API object name into separate words. For example, use `PodTemplateList`, not Pod Template List.
504+
Don't split an API object name into separate words. For example, use PodTemplateList, not Pod Template List.
454505
455506
For more information about PascalCase and code formatting, please review the related guidance on
456507
[Use upper camel case for API objects](/docs/contribute/style/style-guide/#use-upper-camel-case-for-api-objects)
@@ -462,13 +513,10 @@ guidance on [Kubernetes API terminology](/docs/reference/using-api/api-concepts/
462513
### API 资源名称
463514

464515
始终使用[大写驼峰式命名法](https://zh.wikipedia.org/wiki/%E9%A7%9D%E5%B3%B0%E5%BC%8F%E5%A4%A7%E5%B0%8F%E5%AF%AB)
465-
(PascalCase)和代码格式来表达 API 资源名称。
466-
467-
对于 HTML 文档中的内联代码,请使用 `<code>` 标记。
468-
在 Markdown 文档中,使用反引号 (`` ` ``)。
516+
(也称为 PascalCase)来表达 API 资源名称。不要使用代码格式书写 API 类别。
469517

470518
不要将 API 对象的名称切分成多个单词。
471-
例如请使用 `PodTemplateList` 而非 `Pod Template List`
519+
例如请使用 PodTemplateList 而非 Pod Template List。
472520

473521
有关 PascalCase 和代码格式的更多信息,
474522
请查看[对 API 对象使用大写驼峰式命名法](/zh-cn/docs/contribute/style/style-guide/#use-upper-camel-case-for-api-objects)
@@ -485,7 +533,7 @@ guidance on [Kubernetes API terminology](/docs/reference/using-api/api-concepts/
485533
{{< table caption = "Do and Don't - Don't include the command prompt" >}}
486534
Do | Don't
487535
:--| :-----
488-
kubectl get pods | $ kubectl get pods
536+
`kubectl get pods` | `$ kubectl get pods`
489537
{{< /table >}}
490538
-->
491539
## 代码段格式 {#code-snippet-formatting}
@@ -495,7 +543,7 @@ kubectl get pods | $ kubectl get pods
495543
{{< table caption = "命令行提示符约定" >}}
496544
可以 | 不可以
497545
:--| :-----
498-
kubectl get pods | $ kubectl get pods
546+
`kubectl get pods` | `$ kubectl get pods`
499547
{{< /table >}}
500548

501549
<!--

0 commit comments

Comments
 (0)