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: README.md
+71-36
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,23 @@ The markdown generation is entirely [gotemplate](https://golang.org/pkg/text/tem
10
10
from charts and generates a number of sub-templates that can be referenced in a template file (by default `README.md.gotmpl`).
11
11
If no template file is provided, the tool has a default internal template that will generate a reasonably formatted README.
12
12
13
+
In particular, this tool will auto-detect descriptions of fields from comments:
14
+
```yaml
15
+
controller:
16
+
# -- Configure the healthcheck for the ingress controller
17
+
livenessProbe:
18
+
httpGet:
19
+
# -- This is the liveness check endpoint
20
+
path: /healthz
21
+
```
22
+
23
+
Resulting in a resulting README section like so:
24
+
25
+
| Key | Type | Default | Description |
26
+
|-----|------|---------|-------------|
27
+
| controller.livenessProbe | object | `{"httpGet":{"path":"/healthz","port":8080}}` | Configure the healthcheck for the ingress controller |
28
+
| controller.livenessProbe.httpGet.path | string | `"/healthz"` | This is the liveness check endpoint |
29
+
13
30
14
31
## Installation
15
32
helm-docs can be installed using [homebrew](https://brew.sh/):
@@ -36,7 +53,20 @@ GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
36
53
37
54
## Usage
38
55
39
-
## Using binary directly
56
+
## Pre-commit hook
57
+
58
+
If you want to automatically generate `README.md` files with a pre-commit hook, make sure you
59
+
[install the pre-commit binary](https://pre-commit.com/#install), and add a [.pre-commit-config.yaml file](./.pre-commit-config.yaml)
60
+
to your project. Then run:
61
+
62
+
```bash
63
+
pre-commit install
64
+
pre-commit install-hooks
65
+
```
66
+
67
+
Future changes to your chart's `requirements.yaml`, `values.yaml`, `Chart.yaml`, or `README.md.gotmpl` files will cause an update to documentation when you commit.
68
+
69
+
## Running the binary directly
40
70
41
71
To run and generate documentation into READMEs for all helm charts within or recursively contained by a directory:
42
72
@@ -51,22 +81,15 @@ for every chart that it finds.
51
81
52
82
## Using docker
53
83
54
-
You can mount directory with charts under `/helm-docs` within container.
55
-
56
-
Print generated documentation to stdout rather than modifying READMEs:
57
-
58
-
```bash
59
-
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest --dry-run
60
-
```
84
+
You can mount a directory with charts under `/helm-docs` within the container.
61
85
62
-
Overwrite READMEs within mounted directory:
86
+
Then run:
63
87
64
88
```bash
65
-
docker run --rm -v"$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest
89
+
docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest
66
90
```
67
91
68
92
# Building from source
69
-
70
93
Notice that you need to have build chain toolkit for given platform and golang installed.
71
94
Next you may need to export some vars to build standalone, non-linked binary for given platform and architecture:
72
95
@@ -153,9 +176,10 @@ Chart.yaml file for a chart to skip processing for it.
153
176
154
177
## values.yaml metadata
155
178
This tool can parse descriptions and defaults of values from `values.yaml` files. The defaults are pulled directly from
156
-
the yaml in the file. Descriptions can be added for parameters by specifying the full path of the value and
157
-
a particular comment format. I invite you to check out the [example-charts](./example-charts) to see how this is done in
158
-
practice. In order to add a description for a parameter you need only put a comment somewhere in the file of the format:
179
+
the yaml in the file.
180
+
181
+
It was formerly the case that descriptions had to be specified with the full path of the yaml field. This is no longer
182
+
the case, although it is still supported. Where before you would document a values.yaml like so:
159
183
160
184
```yaml
161
185
controller:
@@ -168,8 +192,28 @@ controller:
168
192
replicas: 2
169
193
```
170
194
171
-
Note that comments can continue on the next line. In that case leave out the double dash, and the lines will simply be
172
-
appended with a space in-between.
195
+
You may now equivelantly write:
196
+
```yaml
197
+
controller:
198
+
publishService:
199
+
# -- Whether to expose the ingress controller to the public world
200
+
enabled: false
201
+
202
+
# -- Number of nginx-ingress pods to load balance between. Do not set this below 2.
203
+
replicas: 2
204
+
```
205
+
206
+
There are a number of limitations to this comment format, the foremost being that they can only comprise a single line and while
207
+
the old-style comment for a field could appear anywhere in the file, the new comment must appear **on the line immediately preceding the field being documented.**
208
+
209
+
Additionally, there are a number of methods for encoding more data in the old comment format, documented later in this guide. These
210
+
extensions are largely not supported with the new _auto-detection_ format.
211
+
212
+
I invite you to check out the [example-charts](./example-charts) to see how this is done in practice. The `but-auto-comments`
213
+
examples in particular document the new comment format.
214
+
215
+
Note that comments of the old form can continue on the next line. In that case leave out the double dash, and the lines
216
+
will simply be appended with a space in-between.
173
217
174
218
The following rules are used to determine which values will be added to the values table in the README:
175
219
@@ -185,10 +229,10 @@ e.g. In this case, both `controller.livenessProbe` and `controller.livenessProbe
185
229
the values table, but `controller.livenessProbe.httpGet.port` will not
186
230
```yaml
187
231
controller:
188
-
# controller.livenessProbe -- Configure the healthcheck for the ingress controller
232
+
# -- Configure the healthcheck for the ingress controller
189
233
livenessProbe:
190
234
httpGet:
191
-
# controller.livenessProbe.httpGet.path -- This is the liveness check endpoint
235
+
# -- This is the liveness check endpoint
192
236
path: /healthz
193
237
port: http
194
238
```
@@ -207,7 +251,7 @@ and `controller.livenessProbe.httpGet.port` will be added to the table, with our
207
251
controller:
208
252
livenessProbe:
209
253
httpGet:
210
-
# controller.livenessProbe.httpGet.path -- This is the liveness check endpoint
254
+
# -- This is the liveness check endpoint
211
255
path: /healthz
212
256
port: http
213
257
```
@@ -222,11 +266,14 @@ Results in:
222
266
223
267
### nil values
224
268
If you would like to define a key for a value, but leave the default empty, you can still specify a description for it
225
-
as well as a type. Like so:
269
+
as well as a type. This is possible with both the old and the new comment format:
226
270
```yaml
227
271
controller:
228
-
# controller.replicas -- (int) Number of nginx-ingress pods to load balance between
272
+
# -- (int) Number of nginx-ingress pods to load balance between
229
273
replicas:
274
+
275
+
# controller.image -- (string) Number of nginx-ingress pods to load balance between
276
+
image:
230
277
```
231
278
This could be useful when wanting to enforce user-defined values for the chart, where there are no sensible defaults.
232
279
@@ -242,12 +289,13 @@ service:
242
289
```
243
290
244
291
The order is important. The name must be spelled just like the column heading. The first comment must be the
245
-
one specifying the key. The "@default" comment must follow.
292
+
one specifying the key. The "@default" comment must follow. This is only possible with the old comment format
246
293
247
294
See [here](./example-charts/custom-template/values.yaml) for an example.
248
295
249
296
### Spaces and Dots in keys
250
-
If a key name contains any "." or " " characters, that section of the path must be quoted in description comments e.g.
297
+
In the old-style comment, if a key name contains any "." or " " characters, that section of the path must be quoted in
298
+
description comments e.g.
251
299
252
300
```yaml
253
301
service:
@@ -259,16 +307,3 @@ configMap:
259
307
# configMap."not real config param" -- A completely fake config parameter for a useful example
260
308
not real config param: value
261
309
```
262
-
263
-
## Pre-commit hook
264
-
265
-
If you want to automatically generate `README.md` files with a pre-commit hook, make sure you
266
-
[install the pre-commit binary](https://pre-commit.com/#install), and add a [.pre-commit-config.yaml file](./.pre-commit-config.yaml)
267
-
to your project. Then run:
268
-
269
-
```bash
270
-
pre-commit install
271
-
pre-commit install-hooks
272
-
```
273
-
274
-
Future changes to your chart's `requirements.yaml`, `values.yaml`, `Chart.yaml`, or `README.md.gotmpl` files will cause an update to documentation when you commit.
| controller.extraVolumes | list |`[{"configMap":{"name":"nginx-ingress-config"},"name":"config-volume"}]`| Additional volumes to be mounted into the ingress controller container |
| controller.ingressClass | string |`"nginx"`| Name of the ingress class to route through this controller |
33
+
| controller.livenessProbe | object |`{"httpGet":{"path":"/healthz","port":8080}}`| Configure the healthcheck for the ingress controller |
34
+
| controller.livenessProbe.httpGet.path | string |`"/healthz"`| This is the liveness check endpoint |
35
+
| controller.name | string |`"controller"`||
36
+
| controller.persistentVolumeClaims | list |`[]`| List of persistent volume claims to create |
37
+
| controller.podLabels | object |`{}`| The labels to be applied to instances of the controller pod |
38
+
| controller.publishService.enabled | bool |`false`| Whether to expose the ingress controller to the public world |
39
+
| controller.replicas | int |`nil`| Number of nginx-ingress pods to load balance between |
40
+
| controller.service.annotations."external-dns.alpha.kubernetes.io/hostname" | string |`"stupidchess.jmn23.com"`| Hostname to be assigned to the ELB for the service |
| elasticsearch.clusterHealthCheckParams | string |`"wait_for_status=yellow&timeout=1s"`| The Elasticsearch cluster health status params that will be used by readinessProbe command |
24
+
| elasticsearch.clusterHealthCheckParamsDescription | string |`""`| Now let's put some special characters in the description: wait_for_status=yellow&timeout=1s |
25
+
| htmlSnippets.one | string |`"<html>\n <head></head>\n <body>\n <h1>Is this right, I don't know html</h1>\n </body>\n</html>\n"`||
26
+
| htmlSnippets.three | string |`"<html><head></head></html>"`| Another description |
27
+
| htmlSnippets.two | string |`""`| Let's put it in the description <html></html> |
Copy file name to clipboardExpand all lines: example-charts/special-characters/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -23,5 +23,5 @@ A chart demonstrating handling of special characters in values files
23
23
| elasticsearch.clusterHealthCheckParams | string |`"wait_for_status=yellow&timeout=1s"`| The Elasticsearch cluster health status params that will be used by readinessProbe command |
24
24
| elasticsearch.clusterHealthCheckParamsDescription | string |`""`| Now let's put some special characters in the description: wait_for_status=yellow&timeout=1s |
25
25
| htmlSnippets.one | string |`"<html>\n <head></head>\n <body>\n <h1>Is this right, I don't know html</h1>\n </body>\n</html>\n"`||
26
-
| htmlSnippets.three | string | "<html><head></head></html>" | Another description |
26
+
| htmlSnippets.three | string |`"<html><head></head></html>"`| Another description |
27
27
| htmlSnippets.two | string |`""`| Let's put it in the description <html></html> |
0 commit comments