Enum customization & export statements#2
Conversation
|
Hi and thanks for your contribution. I like the part about adding I also like being able to tweak the output of enum generation, but I think it would be better to add that functionality in For one, enums are classes too. Also, Please add unit tests here: https://github.com/ntrrgc/ts-generator/blob/master/src/test/kotlin/me/ntrrgc/tsGenerator/tests/generatorTests.kt It's quite simple: you just have to make a call that generates the code, plus the code that should be generated. |
|
Okay. When I get time (hopefully soon) I will:
|
|
FWIW regarding the It's not even all that hack'ish i think :) (For my part I also added |
|
Can you separate the last commit about bintray shutdown into its own pull request? |
Hi,
I've added two new (small) features that I needed:
This is so I can use them independently, as opposed to as type definitions for other code. To this end I've added a new optional parameter
addExportStatements. When true,exportstatements are added.Secondly, I wanted to be able to customise enum output, so instead of getting ALLCAPS enums, as is the convention in Java/Kotlin, I could have lowercase enums to match my JSON API.
So I've added an
enumTransformerparameter. It is a function that takes the enum class (KClass<*>) and the enum value and returns a string. For my task (lowercase enums) I didn't need per-class behaviour, nor is it needed in the default case. However, I thought that some users might want to format some enums differently than others, so I added that as a parameter.If you're happy with the thrust of these changes, I will write unit tests for them as well, if you would like me too. I didn't want to write unit tests for them until I found out whether you were happy with this API/approach.
Thanks for writing a really useful library!