libelektra
libelektra copied to clipboard
TOML: Trailing Comments in Arrays
In TOML it is possible to have any amount of comments between the last array element and the closing brackets. Given the TOML array:
# Comment assigned to array
array = [ # Comment assigned to element 0
0, # Inline comment assigned to element 0
# Comment assigned to element 1
1 # Inline comment assigned to element 1
# Comment we can't store yet, where/how should we do it?
] # Inline comment assigned to array
How should we store the non-inline comment after value 1, but before the closing brackets? It is neither before any element that has a key, nor is it an inline comment for any key.
This is the same issue as with comments at the end of a file, which is currently solved by assigning this comments to the file-root key (where comment metakeys have the special meaning of being "at the end of the file"). The same solution is not possible in this case, since any comment metakey with index > 0 assigned to a non-root key is interpreted as "comment before the key".
Thank you for asking the question.
In general I am already impressed how far you already went in preserving the file structure. I do not think we need to go further. At least not at the moment. Now is time to get your plugin to be ready as default storage plugin. But if you need a decision for the implementation...
This is the same issue as with comments at the end of a file, which is currently solved by assigning this comments to the file-root key
Yes, I like this solution. We only need to document this. (Ideally with a whole file where you see where all comments go to.)
How should we store the non-inline comment after value 1, but before the closing brackets?
This is a very tricky question but a bit abusing of the possibility that you can add comments everywhere, e.g.:
key # which number do I get?
= # which number do I get?
value # this is clear (#0)
or even:
array # which number do I get?
= # which number do I get?
[ # which number do I get?
0 # which number do I get?
, # this is clear (#0)
I think in such situations, like with whitespaces, we do not need to 100% preserve the initial file. So it is okay if your example gets reordered to:
# Comment assigned to array
# Comment we can't store yet, where/how should we do it?
array = [ # Comment assigned to element 0
0, # Inline comment assigned to element 0
# Comment assigned to element 1
# Comment we can't store yet, where/how should we do it?
1 # Inline comment assigned to element 1
] # Inline comment assigned to array
I am looking forward to a big example file where one sees where everything gets assigned to (full meta key name like comment/#0/...). This file can also be used as test case.
Thanks for the solution! Yeah, I will focus on getting the plugin ready first, and will keep this solution in mind for later implementation.
I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
I closed this issue now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
Currently we lose the comment of the example above:
# Comment assigned to array
array = [ # Comment assigned to element 0
- 0, # Inline comment assigned to element 0
+0, # Inline comment assigned to element 0
# Comment assigned to element 1
- 1 # Inline comment assigned to element 1
- # Comment we can't store yet, where/how should we do it?
+1 # Inline comment assigned to element 1
] # Inline comment assigned to array
I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
I closed this issue now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart: