1

I am evaluating PureConfig to read and write Configuration files.

When writing the configuration file it look like:

# hardcoded value
"name" : "messageBundle",
# hardcoded value
"params" : { ...

Is it possible to have instead of # hardcoded value an actual documentation?

So for example my case class would look like:

@doc("Message Bundle for a Language...")
case class MessageBundle(
    @doc("The name of the ....")
    name: String,
    @doc("The properties ...")
    props: Map[String, String]
) 

Would then be this configuration file:

# Message Bundle for a Language...

# The name of the ....
"name" : "messageBundle",
# The properties ...
"params" : { ...
pme
  • 14,156
  • 3
  • 52
  • 95
  • Excuse me please for not very useful comment, but it seems like a good idea for library. And how this should be generated - via sbt task? Something like `sbt generateConfiTemplate` ? – Ivan Kurchenko Dec 20 '19 at 18:08
  • PureConfig just uses the render function of TypesafeConfig. So the best thing is maybe to put this functionality into PureConfig - but I have not checked if this is easily possible. – pme Dec 20 '19 at 18:21
  • Well, another thing I just thought about is custom `ConfigReader` implementations - so I'm not sure how can documentation be generated in this case, because own `ConfigReader` implementation can drastically differ from derivative implementation - off course it's rare case, but still possible issue. – Ivan Kurchenko Dec 20 '19 at 18:23
  • 1
    Short of putting something useful in the comments, you can at least get rid of the the noisy `# hardcoded value` with `config.render(ConfigRenderOptions.defaults().setOriginComments(false))`. Aside from that, it seems the main blocker is `config`'s spotty handling of comments (they do a good job for parsing them, and a less great job for generating them). – Alec Jan 02 '20 at 17:15

0 Answers0