2017-03-03 03:01:18 +08:00
# <a name="styleAndConventions" />Style and conventions
2015-12-30 12:31:10 +08:00
2017-03-03 03:01:18 +08:00
## <a name="styleOneSentence" />One sentence per line
2016-04-07 02:19:05 +08:00
To keep consistency throughout the Markdown files in the Open Container spec all files should be formatted one sentence per line.
This fixes two things: it makes diffing easier with git and it resolves fights about line wrapping length.
For example, this paragraph will span three lines in the Markdown source.
2017-03-03 03:01:18 +08:00
## <a name="styleHex" />Traditionally hex settings should use JSON integers, not JSON strings
2015-12-30 12:31:10 +08:00
For example, [`"classID": 1048577`][class-id] instead of `"classID": "0x100001"` .
2016-01-15 04:18:52 +08:00
The config JSON isn't enough of a UI to be worth jumping through string < - > integer hoops to support an 0x… form ([source][integer-over-hex]).
2015-12-30 12:31:10 +08:00
2017-03-03 03:01:18 +08:00
## <a name="styleConstantNames" />Constant names should keep redundant prefixes
2015-12-30 12:31:10 +08:00
2016-03-31 01:44:04 +08:00
For example, `CAP_KILL` instead of `KILL` in [**`linux.capabilities`**][capabilities].
2015-12-30 12:31:10 +08:00
The redundancy reduction from removing the namespacing prefix is not useful enough to be worth trimming the upstream identifier ([source][keep-prefix]).
2017-03-03 03:01:18 +08:00
## <a name="styleOptionalSettings" />Optional settings should not have pointer Go types
2015-12-30 12:31:10 +08:00
2017-01-13 07:21:56 +08:00
Because in many cases the Go default for the type is a no-op in the spec (sources [here][no-pointer-for-strings], [here][no-pointer-for-slices], and [here][no-pointer-for-boolean]).
The exceptions are entries where we need to distinguish between “not set” and “set to the Go default for that type” ([source][pointer-when-updates-require-changes]), and this decision should be made on a per-setting case.
2016-01-26 13:00:30 +08:00
2017-02-10 04:32:39 +08:00
## Links
Internal links should be [relative links][markdown-relative-links] when linking to content within the repository.
Internal links should be used inline.
External links should be collected at the bottom of a markdown file and used as referenced links.
See 'Referenced Links' in this [markdown quick reference][markdown-quick-reference].
The use of referenced links in the markdown body helps to keep files clean and organized.
This also facilitates updates of external link targets on a per-file basis.
Referenced links should be kept in two alphabetically sorted sets, a general reference section followed by a man page section.
2017-03-04 04:28:16 +08:00
To keep Pandoc happy, duplicate naming of links within pages listed in the Makefile's `DOC_FILES` variable should be avoided by appending an `_N` to the link tagname, where `N` is some number not currently in use.
2017-02-10 04:32:39 +08:00
The organization and style of an existing reference section should be maintained unless it violates these style guidelines.
An exception to these rules is when a URL is needed contextually, for example when showing an explicit link to the reader.
2016-03-17 10:31:09 +08:00
## Examples
2017-03-03 03:01:18 +08:00
### <a name="styleAnchoring" />Anchoring
2016-03-17 10:31:09 +08:00
For any given section that provides a notable example, it is ideal to have it denoted with [markdown headers][markdown-headers].
The level of header should be such that it is a subheader of the header it is an example of.
#### Example
```markdown
## Some Topic
### Some Subheader
#### Further Subheader
##### Example
To use Further Subheader, ...
### Example
To use Some Topic, ...
```
2017-03-03 03:01:18 +08:00
### <a name="styleContent" />Content
2016-03-17 10:31:09 +08:00
Where necessary, the values in the example can be empty or unset, but accommodate with comments regarding this intention.
Where feasible, the content and values used in an example should convey the fullest use of the data structures concerned.
Most commonly onlookers will intend to copy-and-paste a "working example".
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.
```markdown
### Example
```
```json
{
"foo": null,
"bar": ""
}
```
**vs.**
```markdown
### Example
Following is a fully populated example (not necessarily for copy/paste use)
```
```json
{
"foo": [
1,
2,
3
],
"bar": "waffles",
"bif": {
"baz": "potatoes"
}
}
```
2015-12-30 12:31:10 +08:00
2017-02-10 04:32:39 +08:00
### Links
The following is an example of different types of links.
This is shown as a complete markdown file, where the referenced links are at the bottom.
```markdown
The specification repository's [glossary ](glossary.md ) is where readers can find definitions of commonly used terms.
Readers may click through to the [Open Containers namespace][open-containers] on [GitHub][github].
The URL for the Open Containers link above is: https://github.com/opencontainers
[github]: https://github.com
[open-containers]: https://github.com/opencontainers
```
2015-12-30 12:31:10 +08:00
[capabilities]: config-linux.md#capabilities
config: Single, unified config file
Reverting 7232e4b1 (specs: introduce the concept of a runtime.json,
2015-07-30, #88) after discussion on the mailing list [1]. The main
reason is that it's hard to draw a clear line around "inherently
runtime-specific" or "non-portable", so we shouldn't try to do that in
the spec. Folks who want to flag settings as non-portable for their
own system are welcome to do so (e.g. "we will clobber 'hooks' in
bundles we run") are welcome to do so, but we don't have to have
to split the config into multiple files to do that.
There have been a number of additional changes since #88, so this
isn't a pure Git reversion. Besides copy-pasting and the associated
link-target updates, I've:
* Restored path -> destination, now that the mount type contains both
source and target paths again. I'd prefer 'target' to 'destination'
to match mount(2), but the pre-7232e4b1 phrasing was 'destination'
(possibly due to Windows using 'target' for the source?).
* Restored the Windows mount example to its pre-7232e4b1 content.
* Removed required mounts from the config example (requirements landed
in 3848a238, config-linux: specify the default devices/filesystems
available, 2015-09-09, #164), because specifying those mounts in the
config is now redundant.
* Used headers (vs. bold paragraphs) to set off mount examples so we
get link anchors in the rendered Markdown.
* Replaced references to runtime.json with references to config.json.
[1]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/0QbyJDM9fWY
Subject: Single, unified config file (i.e. rolling back specs#88)
Date: Wed, 4 Nov 2015 09:53:20 -0800
Message-ID: <20151104175320.GC24652@odin.tremily.us>
Signed-off-by: W. Trevor King <wking@tremily.us>
2015-12-29 02:06:40 +08:00
[class-id]: config-linux.md#network
2017-01-13 07:16:08 +08:00
[integer-over-hex]: https://github.com/opencontainers/runtime-spec/pull/267#r48360013
2016-04-05 02:14:04 +08:00
[keep-prefix]: https://github.com/opencontainers/runtime-spec/pull/159#issuecomment-138728337
2017-01-13 07:16:08 +08:00
[no-pointer-for-boolean]: https://github.com/opencontainers/runtime-spec/pull/290#r50296396
[no-pointer-for-slices]: https://github.com/opencontainers/runtime-spec/pull/316#r50782982
2017-01-13 07:21:56 +08:00
[no-pointer-for-strings]: https://github.com/opencontainers/runtime-spec/pull/653#issue-200439192
2017-01-13 07:16:08 +08:00
[pointer-when-updates-require-changes]: https://github.com/opencontainers/runtime-spec/pull/317#r50932706
2016-03-17 10:31:09 +08:00
[markdown-headers]: https://help.github.com/articles/basic-writing-and-formatting-syntax/#headings
2017-02-10 04:32:39 +08:00
[markdown-quick-reference]: https://en.support.wordpress.com/markdown-quick-reference
[markdown-relative-links]: https://help.github.com/articles/basic-writing-and-formatting-syntax/#relative-links