Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Get the description added from the comment added above the variable #67

Open
shyam-ks opened this issue Mar 21, 2023 · 6 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@shyam-ks
Copy link

is there anyway to get the description added from the comment added above the variable

| Parameter                | Description             | Default        |
| ------------------------ | ----------------------- | -------------- |
| `imagePullPolicy` |  | `"Always"` |

# Can it ready the description from 

# Image pull policy description. is there a way to read this?
imagePullPolicy: Always # Now its reading from if its the same line as the variable
@shyam-ks shyam-ks changed the title Q&A: Q&A: Get the description added from the comment added above the variable Mar 21, 2023
@jacobtomlinson
Copy link
Member

This currently isn't possible. I looked into this at some point but couldn't easily figure out how to get consistent behaviour with ruaml. There are questions to be answered like:

  • What happens if there are multiple lines of comments above?
  • What happens if there is a blank line in a multi-line comment?

If someone wants to look into this and open a PR I'd be happy to discuss/review.

@jacobtomlinson jacobtomlinson added enhancement New feature or request help wanted Extra attention is needed labels Mar 22, 2023
@jacobtomlinson jacobtomlinson changed the title Q&A: Get the description added from the comment added above the variable Get the description added from the comment added above the variable Mar 22, 2023
@shyam-ks
Copy link
Author

shyam-ks commented Apr 11, 2023

  • What happens if there are multiple lines of comments above?

If the logic picks the line above the variable as a comment, it will be easier to manage the comments in terms of readability.
Even if there are multi-line comments, reading the one just above the variable should fix it. I believe this is what you meant by multi line comment

# Pull policy
# Image pull policy description. 
imagePullPolicy: Always 

or standardize comments format to use ## or # --

@jacobtomlinson
Copy link
Member

Sure. Do you have any interest in working on this and opening a PR?

@johbo
Copy link

johbo commented May 12, 2023

Just bumped into this, looking currently at Frigate as an alternative to helm-docs.

It is using the prefix # -- to flag something as a comment. The option to put comments right above a parameter is really of value, it's keeping the source file very readable and still allows to automatically generate the README an other auxiliary documentation.

Does anyone already have a view or gut feeling what it would take to add this capability? I've skimmed through the ruyaml documentation and not come across any examples for regular comments. The docs seem to mainly be focused on end-of-line comments attached to something.

Pointer: https://github.com/norwoodj/helm-docs

@jacobtomlinson
Copy link
Member

It would be great to add this but I don't have the capacity to look at this at the moment. I'd be very happy to review PRs from folks.

@d3vv3
Copy link

d3vv3 commented Nov 7, 2024

I have been working on this because we needed to document around 6k values. I have encountered this issue

Coarsely speaking a comment is attached to the latest element encountered to which it can be attached. At the beginning of a document there is no such "latest element" and the comment (block) gets attached to the first element in a special way. And comments can only be attached to mappings and lists, not to scalars.

The best thing I was able to achieve was reading the file from the value line upwards, finding the lines starting with # until a # -- is found. Then using that as the description for the value. Would that be of value for the project? There is no better Python alternative existing atm: see yaml/pyyaml#90

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants