Skip to content

Commit 8d6ec56

Browse files
authored
Merge pull request #541 from Preeticp/codeblock_callouts
Add guidance on explaining commands and variables now that DITA does not allow callouts.
2 parents 0b60674 + 5d34ac6 commit 8d6ec56

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed

supplementary_style_guide/style_guidelines/code-commands.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Reserved MAC addresses for documentation are defined in link:https://www.rfc-edi
116116
[[long-code-examples]]
117117
== Long code examples
118118

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.
120120

121121
[[code-example-syntax-highlighting]]
122122
== Syntax highlighting

supplementary_style_guide/style_guidelines/formatting.adoc

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,111 @@ default active yes yes
5050

5151
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[].
5252

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
126+
127+
[source,yaml,subs="+attributes,+quotes"]
128+
----
129+
cat <<EOF | oc -n {my-product-namespace} create -f -
130+
apiVersion: v1
131+
kind: Secret
132+
metadata:
133+
name: <my-product-database-certificates-secrets>
134+
type: Opaque
135+
stringData:
136+
postgres-ca.pem: |-
137+
-----BEGIN CERTIFICATE-----
138+
<ca-certificate-key>
139+
postgres-key.key: |-
140+
-----BEGIN CERTIFICATE-----
141+
<tls-private-key>
142+
postgres-crt.pem: |-
143+
-----BEGIN CERTIFICATE-----
144+
<tls-certificate-key>
145+
# ...
146+
EOF
147+
----
148+
+
149+
where:
150+
151+
<my-product-database-certificates-secrets>:: Specifies the name of the certificate secret.
152+
<ca-certificate-key>:: Specifies the CA certificate key.
153+
<tls-private-key> Optional:: Specifies the TLS private key.
154+
<tls-certificate-key> Optional:: Specifies the TLS certificate key.
155+
156+
. Use the appropriate admonition style to add notes pertaining to a code block, as described in xref:admonitions[].
157+
53158
[[date-formats]]
54159
== Date formats
55160

@@ -244,6 +349,9 @@ connection.interface-name: enp7s0
244349
----
245350
====
246351

352+
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+
247355
[[user-replaced-values-xml]]
248356
== User-replaced values for XML
249357

@@ -289,5 +397,8 @@ This example renders as follows in HTML:
289397
----
290398
====
291399

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+
292403

293404
// TODO: Add new style entries alphabetically in this file

0 commit comments

Comments
 (0)