Skip to content

Commit 255026f

Browse files
author
Tim Bannister
committed
Write API kinds without code style
1 parent d7fc8eb commit 255026f

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

content/en/docs/contribute/style/style-guide.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,20 @@ The copy is called a "fork". | The copy is called a "fork."
116116

117117
## Inline code formatting
118118

119-
### Use code style for inline code, commands, and API objects {#code-style-inline-code}
119+
### Use code style for inline code, commands {#code-style-inline-code}
120120

121121
For inline code in an HTML document, use the `<code>` tag. In a Markdown
122-
document, use the backtick (`` ` ``).
122+
document, use the backtick (`` ` ``). However, API kinds such as StatefulSet
123+
or ConfigMap are written verbatim (no backticks); this allows using possessive
124+
apostrophes.
123125

124126
{{< table caption = "Do and Don't - Use code style for inline code, commands, and API objects" >}}
125127
Do | Don't
126128
:--| :-----
127-
The `kubectl run` command creates a `Pod`. | The "kubectl run" command creates a pod.
128-
The kubelet on each node acquires a `Lease`… | The kubelet on each node acquires a lease…
129-
A `PersistentVolume` represents durable storage… | A Persistent Volume represents durable storage…
129+
The `kubectl run` command creates a Pod. | The "kubectl run" command creates a Pod.
130+
The kubelet on each node acquires a Lease… | The kubelet on each node acquires a `Lease`
131+
A PersistentVolume represents durable storage… | A `PersistentVolume` represents durable storage…
132+
The CustomResourceDefinition's `.spec.group` field… | The `CustomResourceDefinition.spec.group` field…
130133
For declarative management, use `kubectl apply`. | For declarative management, use "kubectl apply".
131134
Enclose code samples with triple backticks. (\`\`\`)| Enclose code samples with any other syntax.
132135
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**.
@@ -191,37 +194,60 @@ Set the value of `image` to nginx:1.16. | Set the value of `image` to `nginx:1.1
191194
Set the value of the `replicas` field to 2. | Set the value of the `replicas` field to `2`.
192195
{{< /table >}}
193196

197+
However, consider quoting values where there is a risk that readers might confuse the value
198+
with an API kind.
199+
194200
## Referring to Kubernetes API resources
195201

196202
This section talks about how we reference API resources in the documentation.
197203

198204
### Clarification about "resource"
199205

200-
Kubernetes uses the word "resource" to refer to API resources, such as `pod`,
201-
`deployment`, and so on. We also use "resource" to talk about CPU and memory
202-
requests and limits. Always refer to API resources as "API resources" to avoid
203-
confusion with CPU and memory resources.
206+
Kubernetes uses the word _resource_ to refer to API resources. For example,
207+
the URL path `/apis/apps/v1/namespaces/default/deployments/my-app` represents a
208+
Deployment named "my-app" in the "default"
209+
{{< glossary_tooltip text="namespace" term_id="namespace" >}}. In HTTP jargon,
210+
{{< glossary_tooltip text="namespace" term_id="namespace" >}} is a resource -
211+
the same way that all web URLs identify a resource.
212+
213+
Kubernetes documentation also uses "resource" to talk about CPU and memory
214+
requests and limits. It's very often a good idea to refer to API resources
215+
as "API resources"; that helps to avoid confusion with CPU and memory resources,
216+
or with other kinds of resource.
217+
218+
If you are using the lowercase plural form of a resource name, such as
219+
`deployments` or `configmaps`, provide extra written context to help readers
220+
understand what you mean. If you are using the term in a context where the
221+
UpperCamelCase name could work too, and there is a risk of ambiguity,
222+
consider using the API kind in UpperCamelCase.
204223

205224
### When to use Kubernetes API terminologies
206225

207226
The different Kubernetes API terminologies are:
208227

209-
- Resource type: the name used in the API URL (such as `pods`, `namespaces`)
210-
- Resource: a single instance of a resource type (such as `pod`, `secret`)
211-
- Object: a resource that serves as a "record of intent". An object is a desired
228+
- _API kinds_: the name used in the API URL (such as `pods`, `namespaces`).
229+
API kinds are sometimes also called _resource types_.
230+
- _API resource_: a single instance of an API kind (such as `pod`, `secret`).
231+
- _Object_: a resource that serves as a "record of intent". An object is a desired
212232
state for a specific part of your cluster, which the Kubernetes control plane tries to maintain.
233+
All objects in the Kubernetes API are also resources.
213234

214-
Always use "resource" or "object" when referring to an API resource in docs.
215-
For example, use "a `Secret` object" over just "a `Secret`".
235+
For clarity, you can add "resource" or "object" when referring to an API resource in Kubernetes
236+
documentation.
237+
An example: write "a Secret object" instead of "a Secret".
238+
If it is clear just from the capitalization, you don't need to add the extra word.
239+
240+
Consider rephrasing when that change helps avoid misunderstandings. A common situation is
241+
when you want to start a sentence with an API kind, such as “Secret”; because English
242+
and other languages capitalize at the start of sentences, readers cannot tell whether you
243+
mean the API kind or the general concept. Rewording can help.
216244

217245
### API resource names
218246

219247
Always format API resource names using [UpperCamelCase](https://en.wikipedia.org/wiki/Camel_case),
220-
also known as PascalCase, and code formatting.
221-
222-
For inline code in an HTML document, use the `<code>` tag. In a Markdown document, use the backtick (`` ` ``).
248+
also known as PascalCase. Do not write API kinds with code formatting.
223249

224-
Don't split an API object name into separate words. For example, use `PodTemplateList`, not Pod Template List.
250+
Don't split an API object name into separate words. For example, use PodTemplateList, not Pod Template List.
225251

226252
For more information about PascalCase and code formatting, please review the related guidance on
227253
[Use upper camel case for API objects](/docs/contribute/style/style-guide/#use-upper-camel-case-for-api-objects)
@@ -237,7 +263,7 @@ guidance on [Kubernetes API terminology](/docs/reference/using-api/api-concepts/
237263
{{< table caption = "Do and Don't - Don't include the command prompt" >}}
238264
Do | Don't
239265
:--| :-----
240-
kubectl get pods | $ kubectl get pods
266+
`kubectl get pods` | `$ kubectl get pods`
241267
{{< /table >}}
242268

243269
### Separate commands from output

0 commit comments

Comments
 (0)