diff --git a/pkg/document/values.go b/pkg/document/values.go index da0112f..200c972 100644 --- a/pkg/document/values.go +++ b/pkg/document/values.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "regexp" "strings" "github.com/norwoodj/helm-docs/pkg/helm" @@ -32,9 +31,6 @@ const ( timestampTag = "!!timestamp" ) -var autoDocCommentRegex = regexp.MustCompile("^\\s*#\\s*-- (.*)$") -var nilValueTypeRegex = regexp.MustCompile("^\\(.*?\\)") - func formatNextListKeyPrefix(prefix string, index int) string { return fmt.Sprintf("%s[%d]", prefix, index) } @@ -81,16 +77,10 @@ func parseNilValueType(key string, description helm.ChartValueDescription, autoD if len(description.Description) == 0 { description.Description = autoDescription.Description } - // Grab whatever's in between the parentheses of the description and treat it as the type - t := nilValueTypeRegex.FindString(description.Description) - - if len(t) > 0 { - t = t[1 : len(t)-1] - if len(description.Description) > len(t)+3 { - description.Description = description.Description[len(t)+3:] - } else { - description.Description = "" - } + + var t string + if description.ValueType != "" { + t = description.ValueType } else if autoDescription.ValueType != "" { // Use whatever the type recognized by autoDescription parser t = autoDescription.ValueType diff --git a/pkg/document/values_test.go b/pkg/document/values_test.go index 5730b1b..d65436c 100644 --- a/pkg/document/values_test.go +++ b/pkg/document/values_test.go @@ -950,10 +950,10 @@ animals: `) descriptions := map[string]helm.ChartValueDescription{ - "animals.birdCount": {Description: "(int) the number of birds we have"}, - "animals.birds": {Description: "(list) the list of birds we have"}, + "animals.birdCount": {ValueType: intType, Description: "the number of birds we have"}, + "animals.birds": {ValueType: listType, Description: "the list of birds we have"}, "animals.nonWeirdCats": {Description: "the cats that we have that are not weird"}, - "animals.undescribedCount": {Description: "(int)"}, + "animals.undescribedCount": {ValueType: intType, Description: ""}, } valuesRows, err := getSortedValuesTableRows(helmValues, descriptions) @@ -999,8 +999,8 @@ animals: `) descriptions := map[string]helm.ChartValueDescription{ - "animals.birdCount": {Description: "(int) the number of birds we have", Default: "some"}, - "animals.birds": {Description: "(list) the list of birds we have", Default: "explicit"}, + "animals.birdCount": {ValueType: intType, Description: "the number of birds we have", Default: "some"}, + "animals.birds": {ValueType: listType, Description: "the list of birds we have", Default: "explicit"}, "animals.nonWeirdCats": {Description: "the cats that we have that are not weird", Default: "default"}, }