mirror of
https://github.com/apple/pkl.git
synced 2026-05-12 18:10:02 +02:00
Add Kotlin support for "addGeneratedAnnotation" flag (#1115)
This adds logic so that the Kotlin code generator also supports the "addGeneratedAnnotation" flag. Also: * Add Antora documentation * Adjust names (generated-annotation -> add-generated-annotation) * Adjust doc comments
This commit is contained in:
@@ -2029,6 +2029,30 @@ class KotlinCodeGeneratorTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `add generated annotation`() {
|
||||
val files =
|
||||
KotlinCodeGeneratorOptions(addGeneratedAnnotation = true)
|
||||
.generateFiles("com.example.MyModule" to "foo: String")
|
||||
assertThat(files).containsKey("kotlin/com/example/MyModule.kt")
|
||||
assertThat(files["kotlin/com/example/MyModule.kt"])
|
||||
.isEqualTo(
|
||||
"""
|
||||
package com.example
|
||||
|
||||
import kotlin.String
|
||||
import org.pkl.config.java.Generated
|
||||
|
||||
@Generated
|
||||
data class MyModule(
|
||||
val foo: String
|
||||
)
|
||||
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
private fun Map<String, String>.validateContents(
|
||||
vararg assertions: kotlin.Pair<String, List<String>>
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user