Skip to content

Commit 534e59b

Browse files
committed
style: add a section on examples
addressing: * anchoring * content of example Signed-off-by: Vincent Batts <[email protected]>
1 parent f3e5e22 commit 534e59b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

style.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,56 @@ The redundancy reduction from removing the namespacing prefix is not useful enou
1515
So we have a consistent way to identify unset values ([source][optional-pointer]).
1616
The exceptions are entries where the Go default for the type is a no-op in the spec, in which case `omitempty` is sufficient and no pointer is needed (sources [here][no-pointer-for-slices], [here][no-pointer-for-boolean], and [here][pointer-when-updates-require-changes]).
1717

18+
## Examples
19+
20+
### Anchoring
21+
22+
For any given section that provides a notable example, it is ideal to have it denoted with [markdown headers][markdown-headers].
23+
The level of header should be such that it is a subheader of the header it is an example of.
24+
25+
#### Example
26+
27+
```markdown
28+
## some topic
29+
30+
### some subheader
31+
32+
#### further subheader
33+
34+
### Example
35+
36+
```
37+
38+
### Content
39+
40+
Where necessary, the values can be exampled as their empty or unset state, but accommodate with comments regarding this intention.
41+
42+
Where feasible, the content and values used in an example should convey the fullest use of the data structures concerned.
43+
Most commonly onlookers will intend to copy-and-paste a "working example".
44+
If the intention of the example is to be a fully utilized example, rather than a copy-and-paste example, perhaps add a comment as such.
45+
46+
```json
47+
{
48+
"foo": null,
49+
"bar": ""
50+
}
51+
```
52+
53+
**vs.**
54+
55+
```json
56+
{
57+
"foo": [
58+
1,
59+
2,
60+
3
61+
],
62+
"bar": "waffles",
63+
"bif": {
64+
"baz": "potatoes"
65+
}
66+
}
67+
```
1868

1969
[capabilities]: config-linux.md#capabilities
2070
[class-id]: config-linux.md#network
@@ -24,3 +74,4 @@ The exceptions are entries where the Go default for the type is a no-op in the s
2474
[no-pointer-for-slices]: https://github.com/opencontainers/specs/pull/316/files#r50782982
2575
[optional-pointer]: https://github.com/opencontainers/specs/pull/233#discussion_r47829711
2676
[pointer-when-updates-require-changes]: https://github.com/opencontainers/specs/pull/317/files#r50932706
77+
[markdown-headers]: https://help.github.com/articles/basic-writing-and-formatting-syntax/#headings

0 commit comments

Comments
 (0)