You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: supplementary_style_guide/style_guidelines/code-commands.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ Reserved MAC addresses for documentation are defined in link:https://www.rfc-edi
116
116
[[long-code-examples]]
117
117
== Long code examples
118
118
119
-
All code blocks (regardless of length) must be necessary, accurate, and helpful. Code blocks must be as copy-and-paste friendly as possible, with the exception of variables and callouts. The length of the block is irrelevant, within reason, if the code block follows these guidelines.
119
+
All code blocks (regardless of length) must be necessary, accurate, and helpful. Code blocks must be as copy-and-paste friendly as possible, with the exception of variables. The length of the block is irrelevant, within reason, if the code block follows these guidelines.
Copy file name to clipboardExpand all lines: supplementary_style_guide/style_guidelines/formatting.adoc
+111Lines changed: 111 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,111 @@ default active yes yes
50
50
51
51
For commands and command outputs in code blocks, observe the correct markup for user-replaced values, as described in xref:user-replaced-values[] and xref:user-replaced-values-xml[].
52
52
53
+
[[explain-commands-variables-in-code-blocks]]
54
+
== Explain commands and variables in code blocks
55
+
56
+
To explain commands, lines of code, or variables (user-replaced values) used in a code block, follow the code block with the relevant explanation or description of the elements.
57
+
58
+
. Use a simple sentence to explain or describe a single line of command, variable, option, or parameter.
59
+
+
60
+
.Example AsciiDoc: A simple sentence explaining a single coomand
61
+
+
62
+
[source,terminal]
63
+
----
64
+
$ hcp create cluster <platform> --help
65
+
----
66
+
+
67
+
Use the `hcp create cluster` command to create and manage hosted clusters. The supported platforms are `aws`, `agent`, and `kubevirt`.
68
+
+
69
+
. Use a bulleted list to describe the structure of a sample YAML file or explain multiple lines of code in a code block.
70
+
** List the explanations in the order in which they appear in the code block.
71
+
+
72
+
.Example AsciiDoc: A bulleted list explaining the structure of an YAML file
73
+
74
+
[source,yaml]
75
+
----
76
+
apiVersion: tekton.dev/v1
77
+
kind: Pipeline
78
+
metadata:
79
+
name: build-and-deploy
80
+
spec:
81
+
workspaces:
82
+
- name: shared-workspace
83
+
params:
84
+
...
85
+
tasks:
86
+
- name: build-image
87
+
taskRef:
88
+
resolver: cluster
89
+
params:
90
+
- name: kind
91
+
value: task
92
+
- name: name
93
+
value: buildah
94
+
- name: namespace
95
+
value: openshift-pipelines
96
+
workspaces:
97
+
- name: source
98
+
workspace: shared-workspace
99
+
params:
100
+
- name: TLSVERIFY
101
+
value: "false"
102
+
- name: IMAGE
103
+
value: $(params.IMAGE)
104
+
runAfter:
105
+
- fetch-repository
106
+
- name: apply-manifests
107
+
taskRef:
108
+
name: apply-manifests
109
+
workspaces:
110
+
- name: source
111
+
workspace: shared-workspace
112
+
runAfter:
113
+
- build-image
114
+
...
115
+
----
116
+
117
+
* `workspaces`: List of pipeline workspaces shared between the tasks defined in the pipeline. A pipeline can define as many workspaces as required. In this example, only one workspace named `shared-workspace` is declared.
118
+
* `tasks`: Definition of tasks used in the pipeline. This snippet defines two tasks, `build-image` and `apply-manifests`.
119
+
* `tasks.name.workspaces`: List of task workspaces used in the `build-image` and `apply-manifests` tasks. A task definition can include as many workspaces as it requires. However, it is recommended that a task uses at most one writable workspace. In this example, both the tasks share a common task workspace named `source`, which in turn shares the pipeline workspace named `shared-workspace`.
120
+
121
+
. Use a definition list to explain multiple options, parameters, variables, placeholders, or UI elements.
122
+
** List the parameters/variables in the order in which they appear in the code block.
123
+
** Introduce definition lists with "where:" and begin each variable description with "Specifies".
124
+
+
125
+
.Example AsciiDoc: A definition list explaining user-replaced values
To explain user-replaced values used in a code block, you must use a definition list following the code block. See xref:explain-commands-variables-in-code-blocks[] for details.
353
+
354
+
247
355
[[user-replaced-values-xml]]
248
356
== User-replaced values for XML
249
357
@@ -289,5 +397,8 @@ This example renders as follows in HTML:
289
397
----
290
398
====
291
399
400
+
To explain user-replaced values used in a code block, you must use a definition list following the code block. See xref:explain-commands-variables-in-code-blocks[] for details.
401
+
402
+
292
403
293
404
// TODO: Add new style entries alphabetically in this file
0 commit comments