aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/translators/utils.kt
blob: 96d3035a01790ef887f5082ddccc5829d6b9d60c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package translators

import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.model.doc.Description
import org.jetbrains.dokka.model.doc.Text

fun DModule.documentationOf(className: String, functionName: String): String {
    return (packages.single()
        .classlikes.single { it.name == className }
        .functions.single { it.name == functionName }
        .documentation.values.singleOrNull()
        ?.children?.singleOrNull()
        .run { this as? Description }
        ?.root?.children?.single() as? Text)
        ?.body.orEmpty()
}