-
Notifications
You must be signed in to change notification settings - Fork 966
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
Empty comments #603
Comments
Skipping empty descriptions seems OK. Could allow null to be passed to fromAnyRef maybe and then skip null descriptions instead, might be cleaner, I think treating empty string as unset often ends in tears. Implementation-wise I guess SimpleConfigOrigin would need the notion of an unset description and then at render time it could be skipped. I probably wouldn't make the For changing the default, the additional API and docs needed in ConfigRenderOptions for that feels a bit heavy to me. I think it might be hard to write the docs in a way that makes much sense. ("The description to render in a comment above values which were created in code rather than parsed from a file" ? seems a bit obscure, I feel like next to no one would use it...) Note that if the format of the output matters to you much, the right direction is probably to be using and enhancing the |
Thanks for the detailed answer. |
I don't have immediate plans to make this PR but if someone did I would try allowing a null originDescription when creating a new origin here: config/config/src/main/java/com/typesafe/config/impl/ConfigImpl.java Lines 185 to 190 in e1c2640
So allow a null originDescription to be passed in. And have tests for the null-passed-in-to-ConfigValueFactory.fromAnyRef case, for sure. Then rename SimpleConfigOrigin.description field to descriptionOrNull
In here if descriptionOrNull is null, default description to
Add a method to ConfigOrigin Not sure that will work out but that' what I'd try. |
Why not just skip comment rendering if |
There are two places with next code: config/config/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java Lines 488 to 498 in ea45ea3
Maybe, replace it to something like this? if (options.getOriginComments()) {
String desc = v.origin().description();
if (!desc.isEmpty()) {
String[] lines = desc.split("\n");
for (String l : lines) {
indent(sb, indent + 1, options);
sb.append('#');
if (!l.isEmpty())
sb.append(' ');
sb.append(l);
sb.append("\n");
}
}
} |
Why do you use a
final private static
default comment?Maybe you add possibility to set default comment in ConfigRenderOptions, for example?
Also, if I use
ConfigValueFactory.fromAnyRef(obj, "")
then generated empty comment with '#'.Maybe in the case of empty lines do not need to generate a comment?
The text was updated successfully, but these errors were encountered: