All Downloads are FREE. Search and download functionalities are using the official Maven repository.

poet.KDoc.kt Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
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