Skip to content

Commit e1cd68b

Browse files
committed
modify comment continuation regex
1 parent 50af931 commit e1cd68b

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

example-charts/custom-value-notation-type/values.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,24 @@ persistence:
204204
# @section
205205
# Sometimes you need a very long description
206206
# for your values.
207-
#
207+
#
208208
# Any comment section for a given key with **@section** attribute
209209
# will be treated as raw string and stored as is.
210210
# Since it generates in Markdown format, you can do something like this:
211-
#
211+
#
212212
# ```yaml
213213
# hello:
214214
# bar: true
215215
# ```
216-
#
216+
#
217217
# Markdown also accept subset of HTML tags. So you can also do this:
218-
#
218+
#
219219
# <details>
220220
# <summary>+Expand</summary>
221221
#
222222
# ```bash
223223
# execute some command
224224
# ```
225-
#
225+
#
226226
# </details>
227227
sampleYaml: {}

pkg/document/values_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,12 +1305,12 @@ func TestMultilineDescriptionSection(t *testing.T) {
13051305
animals:
13061306
# -- (list) I mean, dogs are quite nice too...
13071307
# @section
1308-
#
1308+
#
13091309
# List of default dogs:
13101310
# - Umbra
13111311
# - Penumbra
13121312
# - Somnus
1313-
#
1313+
#
13141314
# @default -- The list of dogs that _I_ own
13151315
dogs:
13161316
`)
@@ -1324,7 +1324,7 @@ animals:
13241324
assert.Equal(t, listType, valuesRows[0].Type)
13251325
assert.Equal(t, "The list of dogs that _I_ own", valuesRows[0].AutoDefault)
13261326
assert.Equal(t, "", valuesRows[0].Default)
1327-
assert.Equal(t, "I mean, dogs are quite nice too...\n\nList of default dogs:\n - Umbra\n - Penumbra\n - Somnus\n", valuesRows[0].Description)
1327+
assert.Equal(t, "I mean, dogs are quite nice too...\n\nList of default dogs:\n- Umbra\n- Penumbra\n- Somnus\n", valuesRows[0].Description)
13281328
}
13291329

13301330
func TestExtractValueNotationType(t *testing.T) {

pkg/helm/chart_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
var valuesDescriptionRegex = regexp.MustCompile("^\\s*#\\s*(.*)\\s+--\\s*(.*)$")
1818
var sectionDescriptionRegex = regexp.MustCompile("^\\s*#\\s+@section")
19-
var commentContinuationRegex = regexp.MustCompile("^\\s*# (.*)$")
19+
var commentContinuationRegex = regexp.MustCompile("^\\s*#(\\s*)(.*)$")
2020
var defaultValueRegex = regexp.MustCompile("^\\s*# @default -- (.*)$")
2121
var valueTypeRegex = regexp.MustCompile("^\\((.*?)\\)\\s*(.*)$")
2222
var valueNotationTypeRegex = regexp.MustCompile("^\\s*#\\s+@notationType\\s+--\\s+(.*)$")

pkg/helm/comment.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,14 @@ func ParseComment(commentLines []string) (string, ChartValueDescription) {
4141
commentContinuationMatch := commentContinuationRegex.FindStringSubmatch(line)
4242

4343
if isSection {
44-
if len(commentContinuationMatch) > 0 {
45-
c.Description += "\n"
46-
}
4744

4845
if len(commentContinuationMatch) > 1 {
49-
c.Description += commentContinuationMatch[1]
46+
c.Description += "\n" + commentContinuationMatch[2]
5047
}
5148
continue
5249
} else {
5350
if len(commentContinuationMatch) > 1 {
54-
c.Description += " " + commentContinuationMatch[1]
51+
c.Description += " " + commentContinuationMatch[2]
5552
}
5653
continue
5754
}

0 commit comments

Comments
 (0)