poet.KDoc.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-code-generation Show documentation
Show all versions of kotlin-code-generation Show documentation
Wrapping core components for kotlin code generation with kotlin-poet.
package io.toolisticon.kotlin.generation.poet
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import java.util.function.Supplier
/**
* For all [com.squareup.kotlinpoet.Documentable] types, wrap the [CodeBlock] in [KDoc].
*/
@JvmInline
@ExperimentalKotlinPoetApi
value class KDoc(private val value: CodeBlock) : Supplier {
companion object {
fun of(doc: String) = of(FormatSpecifier.LITERAL, doc)
fun of(format: String, first: Any, vararg other: Any) = KDoc(
value = CodeBlock.of(
format = format,
args = (listOf(first, *other).toTypedArray())
)
)
}
override fun get(): CodeBlock = value
override fun toString() = get().toString()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy