-
Notifications
You must be signed in to change notification settings - Fork 280
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
Preserving comments on pkl eval #690
Comments
As far as I know, this isn’t currently possible. How would you like comments to be propagated from the Pkl template to the (YAML?) output? |
I think similar to how dynamic objects are not supported in other template format. The process can also strip comments on selected output. |
What if you modify an output with an custom |
Something that you can do quite easily is to add top-level comments to a document, like so: output {
text = """
// This is a rendered file! DO NOT EDIT
\(super.text)
"""
} But it's much less trivial if you want comments interspersed throughout the rendered file; most comments (line comments and block comments) are treated as whitespace and thrown away. However, doc comments can be obtained through reflection: /// Here are my doc comments
module myModule
import "pkl:reflect"
local mod = reflect.Module(module)
myDocComments = mod.docComment This produces:
Our code generators for Swift and Go are written in Pkl, and use reflection to obtain these doc comments, which then get rendered as comments in the target language. E.g. |
I have a PKL template configuration file, and I'd like to ensure that comments are preserved after pkl eval, as the output is the user-facing configuration file. Is there a way to retain the comments in the generated document on pkl eval?
The text was updated successfully, but these errors were encountered: