Skip to content

Commit

Permalink
modify comment continuation regex
Browse files Browse the repository at this point in the history
  • Loading branch information
lucernae committed Jul 2, 2021
1 parent 50af931 commit e1cd68b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions example-charts/custom-value-notation-type/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,24 @@ persistence:
# @section
# Sometimes you need a very long description
# for your values.
#
#
# Any comment section for a given key with **@section** attribute
# will be treated as raw string and stored as is.
# Since it generates in Markdown format, you can do something like this:
#
#
# ```yaml
# hello:
# bar: true
# ```
#
#
# Markdown also accept subset of HTML tags. So you can also do this:
#
#
# <details>
# <summary>+Expand</summary>
#
# ```bash
# execute some command
# ```
#
#
# </details>
sampleYaml: {}
6 changes: 3 additions & 3 deletions pkg/document/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,12 +1305,12 @@ func TestMultilineDescriptionSection(t *testing.T) {
animals:
# -- (list) I mean, dogs are quite nice too...
# @section
#
#
# List of default dogs:
# - Umbra
# - Penumbra
# - Somnus
#
#
# @default -- The list of dogs that _I_ own
dogs:
`)
Expand All @@ -1324,7 +1324,7 @@ animals:
assert.Equal(t, listType, valuesRows[0].Type)
assert.Equal(t, "The list of dogs that _I_ own", valuesRows[0].AutoDefault)
assert.Equal(t, "", valuesRows[0].Default)
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)
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)
}

func TestExtractValueNotationType(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/helm/chart_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var valuesDescriptionRegex = regexp.MustCompile("^\\s*#\\s*(.*)\\s+--\\s*(.*)$")
var sectionDescriptionRegex = regexp.MustCompile("^\\s*#\\s+@section")
var commentContinuationRegex = regexp.MustCompile("^\\s*# (.*)$")
var commentContinuationRegex = regexp.MustCompile("^\\s*#(\\s*)(.*)$")
var defaultValueRegex = regexp.MustCompile("^\\s*# @default -- (.*)$")
var valueTypeRegex = regexp.MustCompile("^\\((.*?)\\)\\s*(.*)$")
var valueNotationTypeRegex = regexp.MustCompile("^\\s*#\\s+@notationType\\s+--\\s+(.*)$")
Expand Down
7 changes: 2 additions & 5 deletions pkg/helm/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ func ParseComment(commentLines []string) (string, ChartValueDescription) {
commentContinuationMatch := commentContinuationRegex.FindStringSubmatch(line)

if isSection {
if len(commentContinuationMatch) > 0 {
c.Description += "\n"
}

if len(commentContinuationMatch) > 1 {
c.Description += commentContinuationMatch[1]
c.Description += "\n" + commentContinuationMatch[2]
}
continue
} else {
if len(commentContinuationMatch) > 1 {
c.Description += " " + commentContinuationMatch[1]
c.Description += " " + commentContinuationMatch[2]
}
continue
}
Expand Down

0 comments on commit e1cd68b

Please sign in to comment.