1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-24 19:47:11 -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>
@Directive
public fun myConfig(project: Project, init: Info.() -> Unit) : Info {
val info = Info()
info.init()
public fun myConfig(init: Info.() -> Unit) = Info().apply {
init()
(Kobalt.findPlugin("my-plug-in") as MyPlugin).info = info
return info
}
</pre>
this
}</pre>
<p>
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...
</p>
<h2 class="section" id="tasks">Tasks</h2>