Generated Javascript bindings for Kotlin


#1

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

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)

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)

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

Fabian