2015-11-03 21:27:24 +00:00
|
|
|
|
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
|
|
|
|
|
2016-06-10 23:46:46 +00:00
|
|
|
|
<!-- BEGIN STRIP_FOR_RELEASE -->
|
|
|
|
|
|
|
|
|
|
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
|
|
|
|
width="25" height="25">
|
|
|
|
|
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
|
|
|
|
width="25" height="25">
|
|
|
|
|
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
|
|
|
|
width="25" height="25">
|
|
|
|
|
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
|
|
|
|
width="25" height="25">
|
|
|
|
|
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
|
|
|
|
width="25" height="25">
|
|
|
|
|
|
|
|
|
|
<h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2>
|
|
|
|
|
|
|
|
|
|
If you are using a released version of Kubernetes, you should
|
|
|
|
|
refer to the docs that go with that version.
|
|
|
|
|
|
|
|
|
|
Documentation for other releases can be found at
|
|
|
|
|
[releases.k8s.io](http://releases.k8s.io).
|
|
|
|
|
</strong>
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
<!-- END STRIP_FOR_RELEASE -->
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
# Document Conventions
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
Updated: 11/3/2015
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
*This document is oriented at users and developers who want to write documents
|
|
|
|
|
for Kubernetes.*
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
**Table of Contents**
|
|
|
|
|
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
- [Document Conventions](#document-conventions)
|
|
|
|
|
- [General Concepts](#general-concepts)
|
|
|
|
|
- [How to Get a Table of Contents](#how-to-get-a-table-of-contents)
|
|
|
|
|
- [How to Write Links](#how-to-write-links)
|
|
|
|
|
- [How to Include an Example](#how-to-include-an-example)
|
|
|
|
|
- [Misc.](#misc)
|
|
|
|
|
- [Code formatting](#code-formatting)
|
|
|
|
|
- [Syntax Highlighting](#syntax-highlighting)
|
|
|
|
|
- [Headings](#headings)
|
2015-11-03 21:27:24 +00:00
|
|
|
|
- [What Are Mungers?](#what-are-mungers)
|
|
|
|
|
- [Auto-added Mungers](#auto-added-mungers)
|
|
|
|
|
- [Unversioned Warning](#unversioned-warning)
|
|
|
|
|
- [Is Versioned](#is-versioned)
|
|
|
|
|
- [Generate Analytics](#generate-analytics)
|
2016-06-03 23:49:35 +00:00
|
|
|
|
- [Generated documentation](#generated-documentation)
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
<!-- END MUNGE: GENERATED_TOC -->
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
## General Concepts
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Each document needs to be munged to ensure its format is correct, links are
|
|
|
|
|
valid, etc. To munge a document, simply run `hack/update-munge-docs.sh`. We
|
|
|
|
|
verify that all documents have been munged using `hack/verify-munge-docs.sh`.
|
|
|
|
|
The scripts for munging documents are called mungers, see the
|
|
|
|
|
[mungers section](#what-are-mungers) below if you're curious about how mungers
|
|
|
|
|
are implemented or if you want to write one.
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
|
|
|
|
## How to Get a Table of Contents
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Instead of writing table of contents by hand, insert the following code in your
|
|
|
|
|
md file:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
2015-11-07 01:19:21 +00:00
|
|
|
|
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
|
|
|
|
<!-- END MUNGE: GENERATED_TOC -->
|
2015-11-03 21:27:24 +00:00
|
|
|
|
```
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
After running `hack/update-munge-docs.sh`, you'll see a table of contents
|
|
|
|
|
generated for you, layered based on the headings.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
## How to Write Links
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
It's important to follow the rules when writing links. It helps us correctly
|
|
|
|
|
versionize documents for each release.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Use inline links instead of urls at all times. When you add internal links to
|
|
|
|
|
`docs/` or `examples/`, use relative links; otherwise, use
|
|
|
|
|
`http://releases.k8s.io/HEAD/<path/to/link>`. For example, avoid using:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
2015-11-07 01:19:21 +00:00
|
|
|
|
[GCE](https://github.com/kubernetes/kubernetes/blob/master/docs/getting-started-guides/gce.md) # note that it's under docs/
|
|
|
|
|
[Kubernetes package](../../pkg/) # note that it's under pkg/
|
|
|
|
|
http://kubernetes.io/ # external link
|
2015-11-03 21:27:24 +00:00
|
|
|
|
```
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
Instead, use:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
```
|
|
|
|
|
[GCE](../getting-started-guides/gce.md) # note that it's under docs/
|
2016-06-10 23:46:46 +00:00
|
|
|
|
[Kubernetes package](http://releases.k8s.io/HEAD/pkg/) # note that it's under pkg/
|
2015-11-07 01:19:21 +00:00
|
|
|
|
[Kubernetes](http://kubernetes.io/) # external link
|
|
|
|
|
```
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
The above example generates the following links:
|
|
|
|
|
[GCE](../getting-started-guides/gce.md),
|
|
|
|
|
[Kubernetes package](http://releases.k8s.io/HEAD/pkg/), and
|
|
|
|
|
[Kubernetes](http://kubernetes.io/).
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
|
|
|
|
## How to Include an Example
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
While writing examples, you may want to show the content of certain example
|
|
|
|
|
files (e.g. [pod.yaml](../user-guide/pod.yaml)). In this case, insert the
|
|
|
|
|
following code in the md file:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN MUNGE: EXAMPLE path/to/file -->
|
|
|
|
|
<!-- END MUNGE: EXAMPLE path/to/file -->
|
|
|
|
|
```
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Note that you should replace `path/to/file` with the relative path to the
|
|
|
|
|
example file. Then `hack/update-munge-docs.sh` will generate a code block with
|
|
|
|
|
the content of the specified file, and a link to download it. This way, you save
|
|
|
|
|
the time to do the copy-and-paste; what's better, the content won't become
|
|
|
|
|
out-of-date every time you update the example file.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
For example, the following:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN MUNGE: EXAMPLE ../user-guide/pod.yaml -->
|
|
|
|
|
<!-- END MUNGE: EXAMPLE ../user-guide/pod.yaml -->
|
|
|
|
|
```
|
|
|
|
|
|
2016-06-03 23:49:35 +00:00
|
|
|
|
generates the following after `hack/update-munge-docs.sh`:
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
2015-11-03 21:27:24 +00:00
|
|
|
|
<!-- BEGIN MUNGE: EXAMPLE ../user-guide/pod.yaml -->
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Pod
|
|
|
|
|
metadata:
|
|
|
|
|
name: nginx
|
|
|
|
|
labels:
|
|
|
|
|
app: nginx
|
|
|
|
|
spec:
|
|
|
|
|
containers:
|
|
|
|
|
- name: nginx
|
|
|
|
|
image: nginx
|
|
|
|
|
ports:
|
|
|
|
|
- containerPort: 80
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
[Download example](../user-guide/pod.yaml?raw=true)
|
|
|
|
|
<!-- END MUNGE: EXAMPLE ../user-guide/pod.yaml -->
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
## Misc.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
### Code formatting
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Wrap a span of code with single backticks (`` ` ``). To format multiple lines of
|
|
|
|
|
code as its own code block, use triple backticks (```` ``` ````).
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
|
|
|
|
### Syntax Highlighting
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Adding syntax highlighting to code blocks improves readability. To do so, in
|
|
|
|
|
your fenced block, add an optional language identifier. Some useful identifier
|
|
|
|
|
includes `yaml`, `console` (for console output), and `sh` (for shell quote
|
|
|
|
|
format). Note that in a console output, put `$ ` at the beginning of each
|
|
|
|
|
command and put nothing at the beginning of the output. Here's an example of
|
|
|
|
|
console code block:
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
2015-11-07 01:19:21 +00:00
|
|
|
|
```console
|
|
|
|
|
|
|
|
|
|
$ kubectl create -f docs/user-guide/pod.yaml
|
|
|
|
|
pod "foo" created
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
which renders as:
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ kubectl create -f docs/user-guide/pod.yaml
|
|
|
|
|
pod "foo" created
|
2015-11-03 21:27:24 +00:00
|
|
|
|
```
|
|
|
|
|
|
2015-11-07 01:19:21 +00:00
|
|
|
|
### Headings
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Add a single `#` before the document title to create a title heading, and add
|
|
|
|
|
`##` to the next level of section title, and so on. Note that the number of `#`
|
|
|
|
|
will determine the size of the heading.
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
|
|
|
|
## What Are Mungers?
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
Mungers are like gofmt for md docs which we use to format documents. To use it,
|
|
|
|
|
simply place
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
2015-11-07 01:19:21 +00:00
|
|
|
|
<!-- BEGIN MUNGE: xxxx -->
|
|
|
|
|
<!-- END MUNGE: xxxx -->
|
2015-11-03 21:27:24 +00:00
|
|
|
|
```
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
in your md files. Note that xxxx is the placeholder for a specific munger.
|
|
|
|
|
Appropriate content will be generated and inserted between two brackets after
|
|
|
|
|
you run `hack/update-munge-docs.sh`. See
|
|
|
|
|
[munger document](http://releases.k8s.io/HEAD/cmd/mungedocs/) for more details.
|
2015-11-07 01:19:21 +00:00
|
|
|
|
|
2015-11-03 21:27:24 +00:00
|
|
|
|
## Auto-added Mungers
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
After running `hack/update-munge-docs.sh`, you may see some code / mungers in
|
|
|
|
|
your md file that are auto-added. You don't have to add them manually. It's
|
|
|
|
|
recommended to just read this section as a reference instead of messing up with
|
|
|
|
|
the following mungers.
|
|
|
|
|
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
### Unversioned Warning
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
UNVERSIONED_WARNING munger inserts unversioned warning which warns the users
|
|
|
|
|
when they're reading the document from HEAD and informs them where to find the
|
|
|
|
|
corresponding document for a specific release.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
|
|
|
|
|
2016-06-10 23:46:46 +00:00
|
|
|
|
<!-- BEGIN STRIP_FOR_RELEASE -->
|
|
|
|
|
<!-- END STRIP_FOR_RELEASE -->
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Is Versioned
|
|
|
|
|
|
2016-05-03 19:31:42 +00:00
|
|
|
|
IS_VERSIONED munger inserts `IS_VERSIONED` tag in documents in each release,
|
|
|
|
|
which stops UNVERSIONED_WARNING munger from inserting warning messages.
|
2015-11-03 21:27:24 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
|
|
|
|
<!-- TAG IS_VERSIONED -->
|
|
|
|
|
<!-- END MUNGE: IS_VERSIONED -->
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Generate Analytics
|
|
|
|
|
|
|
|
|
|
ANALYTICS munger inserts a Google Anaylytics link for this page.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
|
|
|
|
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
|
|
|
|
```
|
|
|
|
|
|
2016-06-03 23:49:35 +00:00
|
|
|
|
# Generated documentation
|
|
|
|
|
|
|
|
|
|
Some documents can be generated automatically. Run `hack/generate-docs.sh` to
|
|
|
|
|
populate your repository with these generated documents, and a list of the files
|
|
|
|
|
it generates is placed in `.generated_docs`. To reduce merge conflicts, we do
|
|
|
|
|
not want to check these documents in; however, to make the link checker in the
|
|
|
|
|
munger happy, we check in a placeholder. `hack/update-generated-docs.sh` puts a
|
|
|
|
|
placeholder in the location where each generated document would go, and
|
|
|
|
|
`hack/verify-generated-docs.sh` verifies that the placeholder is in place.
|
|
|
|
|
|
|
|
|
|
|
2015-11-03 21:27:24 +00:00
|
|
|
|
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
|
|
|
|
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/devel/how-to-doc.md?pixel)]()
|
|
|
|
|
<!-- END MUNGE: GENERATED_ANALYTICS -->
|