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

Add support for multiline comments above property #52

Open
Silthus opened this issue Apr 11, 2024 · 6 comments
Open

Add support for multiline comments above property #52

Silthus opened this issue Apr 11, 2024 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@Silthus
Copy link

Silthus commented Apr 11, 2024

Regarding #51 it would also be very helpful to allow comments above a property to be parsed for the schema tags.

For example:

# My description of this really cool property.
@ @schema title:"My Property"
# @schema maxLength:10;pattern:^[a-z]+$
my_property: some value

The above also defaults a non annotated comment above a property to use as the description. Maybe this could be turned on with a flag in the cli?

@losisin
Copy link
Owner

losisin commented Apr 11, 2024

Top comment is a bit of a problem because of helm-docs. We would need to fight for the same space and eventually something won't work as expected. That's the reason why I decided for line comment which makes it impossible to be multi line. However, I'm open for ideas, suggestions or pull request.

@Silthus
Copy link
Author

Silthus commented Apr 11, 2024

Top comment is a bit of a problem because of helm-docs. We would need to fight for the same space and eventually something won't work as expected. That's the reason why I decided for line comment which makes it impossible to be multi line. However, I'm open for ideas, suggestions or pull request.

And what about being compatible with helm-docs so that the same comments can be used for schema generation and helm-docs? This would even make a lot of sense, since as a Chart Maintainer I would want to generate a schema for validation and tooling support in IDEs and a Readme that contains the descriptions and types as well.

@losisin
Copy link
Owner

losisin commented Apr 11, 2024

I was referring more to development of this plugin. When do you start reading comments and when do you stop? Is there something before or after in comments that should be ignored? Is it with annotation for schema, helm-docs or regular user comment? I avoided all of that by reading line comment. I understand that having all those things is very convenient for end users but moving to top comment will also introduce breaking change for existing users.
For the record, I'm not against it but can't promise anything short term. Maybe for future major release like v2. Until then, I'll leave this issue open so that people can vote 👍 👎

@losisin losisin added the help wanted Extra attention is needed label Apr 11, 2024
@RothAndrew
Copy link

My 2 cents:

  • After having used both helm-docs and a combination of this tool and Adobe's jsonschema2md tool, I like the docs I get from jsonschema2md better. It's also a more generic solution, it works with any JSON schema, not just helm charts.
  • What about making it optional? like helm schema blah blah --above-line-mode (I hate it lol, there's definitely a better name for it out there somewhere). If the optional flag is enabled, the tool doesn't try to fight with helm-docs, it just assumes nothing else is there and it gets to do whatever it wants.

Side node: I'm loving this tool, thanks a bunch @losisin for putting it out there, it's been perfect for my use case. If you turn on your sponsor button I want to buy you a beer or two

@RothAndrew
Copy link

RothAndrew commented Jun 5, 2024

Different idea: if the # @schema comment is on a different line, require a field that ties it back to the yaml key that you want it associated with. This would open things up to let you put it anywhere you want.

image:
  repository: registry.example.com/foo
  tag: 1.2.3

# @schema ref: image; description: Image settings
# @schema ref: image.repository; description: The repository to use; required: true; default: registry.example.com/foo
# @schema ref: image.tag; description: The tag to use

A side benefit would be I can do things this way and make the values.yaml file more readable for downstream users. It takes a lot of brain power to grok the yaml among all the line comments.

This example doesn't demonstrate the original ask of this issue though, as it still does just one line for each. Not sure how multiline might look, maybe something like

# @schema ref: image;
# description: Some long comment that spans
# multiple lines;
# @endschema

IDK, I'm sure there's probably a better way out there.

@Silthus
Copy link
Author

Silthus commented Nov 15, 2024

I like the idea of adding a ref and the @endschema and the benefits it brings :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants