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

[Bug]: Always failing when using the --documentation-strict-mode flag #228

Open
1 task done
wolfwolker opened this issue May 9, 2024 · 1 comment
Open
1 task done
Assignees
Labels
bug Something isn't working triage Issues that need to be triaged and categorized

Comments

@wolfwolker
Copy link

wolfwolker commented May 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When the flag is added to the cli, a complete list of the values keys is dumped, no matter the documentation comments present in the values.yaml file, and it exits. No readme file is generated.

Expected Behavior

List only the undocumented keys of values.yaml file if there is any, ignoring the ones tagged with the @ignored keyword.

Steps to reproduce it

  1. Clone https://github.com/norwoodj/helm-docs repository (master)
  2. Navigate to example-charts/best-values-example
  3. rm README.md
  4. docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest helm-docs -x -l trace
  5. This is the output
time="2024-05-09T18:30:36Z" level=debug msg="No ignore file found at .helmdocsignore, using empty ignore rules"
time="2024-05-09T18:30:36Z" level=info msg="Found Chart directories [.]"
time="2024-05-09T18:30:36Z" level=debug msg="Rendering from optional template files [README.md.gotmpl]"
time="2024-05-09T18:30:36Z" level=warning msg="Error parsing information for chart ., skipping: values without documentation: \nstatefulset\nstatefulset.image\nstatefulset.extraVolumes\nstatefulset.extraVolumes.[0].name\nstatefulset.extraVolumes.[0].emptyDir\nstatefulset.livenessProbe\nstatefulset.livenessProbe.enabled\nstatefulset.podLabels\nconfig\nconfig.databasesToCreate\nconfig.usersToCreate\nconfig.usersToCreate.[0].name\nconfig.usersToCreate.[0].admin\nconfig.usersToCreate.[1].name\nconfig.usersToCreate.[1].readwriteDatabases"
time="2024-05-09T18:30:36Z" level=debug msg="Rendering from optional template files [README.md.gotmpl]"
  1. Same command again removing the -x generates a nice and clean README.md and the terminal output is:
time="2024-05-09T18:30:57Z" level=debug msg="No ignore file found at .helmdocsignore, using empty ignore rules"
time="2024-05-09T18:30:57Z" level=info msg="Found Chart directories [.]"
time="2024-05-09T18:30:57Z" level=debug msg="Rendering from optional template files [README.md.gotmpl]"
time="2024-05-09T18:30:57Z" level=debug msg="Rendering from optional template files [README.md.gotmpl]"
time="2024-05-09T18:30:57Z" level=info msg="Generating README Documentation for chart ."
time="2024-05-09T18:30:57Z" level=debug msg="Did not find template file README.md.gotmpl for chart ., using default template"
time="2024-05-09T18:30:57Z" level=debug msg="Using template files [README.md.gotmpl] for chart ."

I've tried versions from 1.11.0 to latest in docker, and the latest macos binary installed with homebrew, always with same result.

Reference Chart

example-charts/best-values-example present in the helm-docs repository.

Reference Template

No response

Environment

  • Docker image
    • 1.11.2
    • 1.11.3
    • 1.13.3
    • latest
  • homebrew package

Link to helm-docs Logs

No response

Further Information

No response

@wolfwolker wolfwolker added bug Something isn't working triage Issues that need to be triaged and categorized labels May 9, 2024
@dackroyd
Copy link

dackroyd commented Aug 5, 2024

Encountered this myself today while trying to setup strict checks for chart documentation. After a bit of trawling through changes, I loaded it up locally in the debugger.

While stepping through, I discovered that this appears to be an issue relating to parsing of the values descriptions. Specifically, the parsing expects the "old" metadata format, where the leading part of the doc comment includes the field path. If omitting this (using the newer style), the parsing finds no match on the key, so skips adding it to the keyToDescriptions map (match[1] is "" due to their being no explicit key in the comment), and the strict documentation check isn't aware of it, so fails.

if !foundValuesComment {
match := valuesDescriptionRegex.FindStringSubmatch(currentLine)
if len(match) < 3 || match[1] == "" {
continue
}
foundValuesComment = true
commentLines = append(commentLines, currentLine)
continue
}

When the documentation is rendered however, parsing of comments does not skip when this is missing, it gets an empty string:

for i := range commentLines {
match := valuesDescriptionRegex.FindStringSubmatch(commentLines[i])
if len(match) < 3 {
continue
}
valueKey = match[1]
c.Description = match[2]
docStartIdx = i
break
}

This is used as the "auto description" if there isn't an explicit mapping in keyToDescriptions, and ultimately used to render the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issues that need to be triaged and categorized
Projects
None yet
Development

No branches or pull requests

4 participants