Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The description includes description of previous commented values #96

Closed
kaworu opened this issue Apr 27, 2021 · 2 comments · Fixed by #99
Closed

The description includes description of previous commented values #96

kaworu opened this issue Apr 27, 2021 · 2 comments · Fixed by #99

Comments

@kaworu
Copy link

kaworu commented Apr 27, 2021

Might be related to #92

values.yaml

# -- before desc
before: ~

# -- commented desc
#commented: ~

# -- after desc
after: ~

expected output

Key Type Default Description
after string nil after desc
before string nil before desc

actual output

Key Type Default Description
after string nil commented desc -- after desc
before string nil before desc
@kaworu kaworu changed the title The description include description of previous commented values The description includes description of previous commented values Apr 27, 2021
@norwoodj
Copy link
Owner

This is unfortunately a consequence of how the go yaml library works. It treats everything from the first comment as the HeadComment of after. I'm sorry but there's not much I can do here, it's just a quirk of the go yaml library. I suggest you submit an issue against them to break comments on whitespace so the first comment block is parsed independently of the second one.

@bmcustodio
Copy link
Contributor

bmcustodio commented May 20, 2021

I may be definitely missing something, but shouldn't adding something like this

lastIndex := 0
for i, v := range commentLines {
  if strings.HasPrefix(v, "# --") {
    lastIndex = i
  }
}
if lastIndex > 0 {
  return ParseComment(commentLines[lastIndex:])
}

to https://github.com/norwoodj/helm-docs/blob/master/pkg/helm/comment.go#L7 be safe and enough? I made a quick and dirty test and it seemed to work well:


| Key | Type | Default | Description |
|-----|------|---------|-------------|
| after | string | `nil` | after desc |
| before | string | `nil` | before desc |

Opened #99, please feel free to close it if I'm totally wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants