norwoodj/helm-docs

feature: output results as json (or other formats)

Opened this issue · 2 comments

Would be awesome to have an option of exporting the values made available to the go templates, as JSON (or similar), rather than requiring them to be processed through the helm chart. This would allow more complex usecases, like:

  1. direct generation to HTML
  2. dynamic single page applications
  3. having a main/core readme, which includes partial data for each chart, and links to it (think this but more details/info/etc).
  4. allow additional templating that isn't supported by go templates

It should be as straightforward as adding an output-format flag (or similar) that lets you change the format. Multiple formats could be supported relatively easily, without much (if any) maintenance overhead.

I have two primary usecases myself that would greatly benefit from this feature:

  1. I want to generate custom badges, images, and similar within the readme, that use the chart name and description. Some of these things would require URL encoding the results, which isn't possible currently with the templates.
  2. I want to have a "main" readme, which uses data for each of the charts, and generates one readme with basic info about each chart, and links to each charts readme. I would like to take advantage of some of the data that is pulled out by helm-docs.

If I could get the results as JSON, I could pipe that into my own go/pongo2/p2/jinja/etc template.

If this feature makes sense, I can submit a PR to implement.

Nepo26 commented

This makes some sense but I'm not sure if just implementing some output flag would be the way to go about it. But I can see it working.

Can you provide an example of what you are trying to accomplish with the badges and images?

Feel free to submit a PR on this feature @lrstanley as I think it could go well, at least for debugging I know it makes sense.

I looked at implementing this, however, it looks like the "documentation" portion of helm-docs is too engrained at multiple levels today to make it a simple implementation. Ideally, some of the sub-packages should include the entire dataset, which then is passed to docs/templating, however, the document sub-package is doing too much business logic. Feels like an anti-pattern.

May revisit myself if things are refactored in the future.