# Generated Javascript bindings for Kotlin

**URL:** <https://discuss.kotlinlang.org/t/generated-javascript-bindings-for-kotlin/2274>\
**Category:** JavaScript\
**Created:** [February 11, 2017, 10:06am UTC](https://discuss.kotlinlang.org/t/generated-javascript-bindings-for-kotlin/2274 "2017-02-11T10:06:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fab1an](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fab1an/32/1934_2.png) [@fab1an](https://discuss.kotlinlang.org/u/fab1an)\
**Post date:** [February 11, 2017, 10:06am UTC](https://discuss.kotlinlang.org/t/generated-javascript-bindings-for-kotlin/2274/1 "2017-02-11T10:06:17Z")

</div>

Since I wasn’t satisfied with the integration of JS api, I wrote my own converter for the electron API: [https://github.com/fab1an/kotlin-electron-api](https://github.com/fab1an/kotlin-electron-api)

It parses the original markdown source into an xml format like this

```
<file>
    <class title="BrowserWindow">
        <constructor>
            <param optional="true" name="options" type="Object">
                <property optional="true" name="width" type="Integer"/>
                <property optional="true" name="height" type="Integer"/>
                <property optional="true" name="x" type="Integer"/>
...

```

([https://github.com/fab1an/kotlin-electron-api/blob/master/build/api\_docbook/browser-window.source.normalized.xml](https://github.com/fab1an/kotlin-electron-api/blob/master/build/api_docbook/browser-window.source.normalized.xml))

From this generic format, it generates kotlin source. It generates builders for object parameters, so the API can be used like this:

```
val menu = Menu()
menu.append(MenuItem {
    type = "normal"
    label = "New Idea"
    click = { item, window, event ->
        println("clicked")
    }
})

```

([https://github.com/fab1an/kotlin-electron-api/blob/master/generated-api/jsapi/electron/browser-window.kt](https://github.com/fab1an/kotlin-electron-api/blob/master/generated-api/jsapi/electron/browser-window.kt))

The transformations are done via XSLT. Use it if you like it, but everything is subject to change.

Fabian
