Let's say I have a higher order function, which registers some sort of a click listener. I can document its purpose and the listener parameter that's passed in like so:
/**
* Adds a [listener] that's called when the item is clicked.
*
* @param listener The listener to add
*/
fun addClickListener(listener: (count: Int) -> Unit) {
...
}
My question is, is there a way to document the parameters of the listener? This would be count in this example. In my actual use case, I have multiple parameters in my listener.
What I've noticed is that the [listener] text is clickable in the documentation view where I'm using this function, but it just shows an empty dialog about it. Is there a way to describe the parameters there somehow?

For now, I've ended up describing the parameters of the listener with @param blocks at the addClickListener method, but this results in a warning in the IDE, and I'm wondering if there's a more proper way to do it.
As of Kotlin 1.1 there is no syntax for documenting the parameters or return value of a function type used as a function parameter. There is an open YouTrack issue covering this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With