1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-25 12:07:10 -07:00

Better example.

This commit is contained in:
Cedric Beust 2015-11-30 19:11:13 -08:00
parent 34d09120ac
commit 0a6d74672c

View file

@ -339,16 +339,14 @@ myConfig(project) {
<pre> <pre>
@Directive @Directive
public fun myConfig(project: Project, init: Info.() -> Unit) : Info { public fun myConfig(init: Info.() -> Unit) = Info().apply {
val info = Info() init()
info.init()
(Kobalt.findPlugin("my-plug-in") as MyPlugin).info = info (Kobalt.findPlugin("my-plug-in") as MyPlugin).info = info
return info this
} }</pre>
</pre>
<p> <p>
Obviously, you can choose any kind of API to communicate between the directive and its plug-in. In the code Obviously, you can choose any kind of API to communicate between the directive and its plug-in. In the code
above, I chose to directly overrid the entire <code>Info</code> field, but you could instead choose to call above, I chose to directly override the entire <code>Info</code> field, but you could instead choose to call
a function, just set one boolean instead of the whole object, etc... a function, just set one boolean instead of the whole object, etc...
</p> </p>
<h2 class="section" id="tasks">Tasks</h2> <h2 class="section" id="tasks">Tasks</h2>