Skip to content

Commit

Permalink
Merge pull request #142 from j-buczak/rename_section_to_raw
Browse files Browse the repository at this point in the history
Rename @section to @raw
  • Loading branch information
norwoodj authored Jun 29, 2022
2 parents 20b701f + e911c77 commit 43632a0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions example-charts/custom-value-notation-type/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ file, you can see that we modified the column `Key` to also be hyperlinked with
If you view this README.md files in GitHub and click the value's key, you will be directed to the
key location in the `values.yaml` file.

You can also render a raw string into the comments using `@section` annotations.
You can also render a raw string into the comments using `@raw` annotations.
You can jump to [sampleYaml](#sampleYaml) key and check it's description where it
uses HTML `<summary>` tag to collapse some part of the comments.

Expand Down Expand Up @@ -996,7 +996,7 @@ dict
Sometimes you need a very long description
for your values.

Any comment section for a given key with **@section** attribute
Any comment section for a given key with **@raw** attribute
will be treated as raw string and stored as is.
Since it generates in Markdown format, you can do something like this:

Expand Down
2 changes: 1 addition & 1 deletion example-charts/custom-value-notation-type/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ file, you can see that we modified the column `Key` to also be hyperlinked with
If you view this README.md files in GitHub and click the value's key, you will be directed to the
key location in the `values.yaml` file.

You can also render a raw string into the comments using `@section` annotations.
You can also render a raw string into the comments using `@raw` annotations.
You can jump to [sampleYaml](#sampleYaml) key and check it's description where it
uses HTML `<summary>` tag to collapse some part of the comments.

Expand Down
4 changes: 2 additions & 2 deletions example-charts/custom-value-notation-type/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ persistence:


# -- (dict) Values with long description
# @section
# @raw
# Sometimes you need a very long description
# for your values.
#
# Any comment section for a given key with **@section** attribute
# Any comment section for a given key with **@raw** attribute
# will be treated as raw string and stored as is.
# Since it generates in Markdown format, you can do something like this:
#
Expand Down
4 changes: 2 additions & 2 deletions pkg/document/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,11 +1440,11 @@ foo:
assert.Equal(t, "Bar!", valuesRows[0].AutoDescription)
}

func TestMultilineDescriptionSection(t *testing.T) {
func TestMultilineRawDescription(t *testing.T) {
helmValues := parseYamlValues(`
animals:
# -- (list) I mean, dogs are quite nice too...
# @section
# @raw
#
# List of default dogs:
# - Umbra
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 rawDescriptionRegex = regexp.MustCompile("^\\s*#\\s+@raw")
var commentContinuationRegex = regexp.MustCompile("^\\s*#(\\s?)(.*)$")
var defaultValueRegex = regexp.MustCompile("^\\s*# @default -- (.*)$")
var valueTypeRegex = regexp.MustCompile("^\\((.*?)\\)\\s*(.*)$")
Expand Down
10 changes: 5 additions & 5 deletions pkg/helm/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ func ParseComment(commentLines []string) (string, ChartValueDescription) {
c.Description = valueTypeMatch[2]
}

var isSection = false
var isRaw = false

for _, line := range commentLines[docStartIdx+1:] {
sectionFlagMatch := sectionDescriptionRegex.FindStringSubmatch(line)
rawFlagMatch := rawDescriptionRegex.FindStringSubmatch(line)
defaultCommentMatch := defaultValueRegex.FindStringSubmatch(line)
notationTypeCommentMatch := valueNotationTypeRegex.FindStringSubmatch(line)

if !isSection && len(sectionFlagMatch) == 1 {
isSection = true
if !isRaw && len(rawFlagMatch) == 1 {
isRaw = true
continue
}

Expand All @@ -68,7 +68,7 @@ func ParseComment(commentLines []string) (string, ChartValueDescription) {

commentContinuationMatch := commentContinuationRegex.FindStringSubmatch(line)

if isSection {
if isRaw {

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

0 comments on commit 43632a0

Please sign in to comment.