1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-25 03:57:11 -07:00
This commit is contained in:
Cedric Beust 2015-12-05 08:24:14 -08:00
parent 6c17270b8d
commit c11be25ff8

View file

@ -302,10 +302,7 @@ class Info(val publish: Boolean)
</p> </p>
<pre> <pre>
@Directive @Directive
public fun myConfig(init: Info.() -> Unit) = Info().apply { public fun myConfig(init: Info.() -> Unit) = Info().apply { init() }</pre>
init()
this
}</pre>
<p> <p>
The <code>@Directive</code> annotation is not enforced but you should always use it in order to help future tools (e.g. an IDEA plug-in) identify Kobalt directives so they can be treated differently from regular Kotlin functions. The code above defines a <code>myConfig</code> function that accepts a closure as an argument. It creates an <code>Info</code> The <code>@Directive</code> annotation is not enforced but you should always use it in order to help future tools (e.g. an IDEA plug-in) identify Kobalt directives so they can be treated differently from regular Kotlin functions. The code above defines a <code>myConfig</code> function that accepts a closure as an argument. It creates an <code>Info</code>
object, calls the <code>init()</code> function on it (which runs all the code inside that closure) and then return that <code>Info</code> object. object, calls the <code>init()</code> function on it (which runs all the code inside that closure) and then return that <code>Info</code> object.