Hi there! I am still using kotlin 1.3.x and I am t...
# dokka
r
Hi there! I am still using kotlin 1.3.x and I am trying to integrate dokka 0.10.1 on my kotlin multiplatform project. Can someone show me an example of the build.gradle.kts with the dokka task for multiplatform? It’s being difficult to find examples 😞 Thanks in advance!
b
I think dokka supports mpp from 1.4 onwards only
But don't quote me on that
r
According with the documentation they support since 0.10.0 https://github.com/Kotlin/dokka/releases/tag/0.10.0
b
Ah, my bad.
Try checking out 0.10.1 tag and have a look at the readme
r
I’ve tried that but it’s a bit confusing for me
Copy code
kotlin {  // Kotlin Multiplatform plugin configuration
    jvm()
    js("customName")
}

val dokka by getting(DokkaTask::class) {
        outputDirectory = "$buildDir/dokka"
        outputFormat = "html"

        multiplatform { 
            val customName by creating { // The same name as in Kotlin Multiplatform plugin, so the sources are fetched automatically
                includes = listOf("packages.md", "extra.md")
                samples = listOf("samples/basic.kt", "samples/advanced.kt")
            }

            register("differentName") { // Different name, so source roots must be passed explicitly
                targets = listOf("JVM")
                platform = "jvm"
                sourceRoot {
                    path = kotlin.sourceSets.getByName("jvmMain").kotlin.srcDirs.first().toString()
                }
                sourceRoot {
                    path = kotlin.sourceSets.getByName("commonMain").kotlin.srcDirs.first().toString()
                }
            }
        }
    }
These namings
customName
and
differentName
are a bit confusing since I have commonMain, androidMaind and iosMain sources. How can I split the documentation into that packages structure?
b
Just have them the same as sourceSet names
r
I’ve tried this:
Copy code
val dokka by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class) {
    outputDirectory = "$buildDir/dokka"
    outputFormat = "html"

    multiplatform {
        val docs by creating { // The same name as in Kotlin Multiplatform plugin, so the sources are fetched automatically
            includes = listOf("packages.md", "extra.md")
//            samples = listOf("samples/basic.kt", "samples/advanced.kt")

            includeNonPublic = false
            skipDeprecated = false
            reportUndocumented = false
            skipEmptyPackages = true
        }

        register("differentName") { // Different name, so source roots must be passed explicitly
            targets = listOf("common", "jvm", "native")
            sourceRoot {
                path = kotlin.sourceSets.getByName("commonMain").kotlin.srcDirs.first().toString()
                platform = "common"
            }
            sourceRoot {
                path = kotlin.sourceSets.getByName("androidMain").kotlin.srcDirs.first().toString()
                platform = "jvm"
            }
            sourceRoot {
                path = kotlin.sourceSets.getByName("iosMain").kotlin.srcDirs.first().toString()
                platform = "native"
            }
        }
    }
}
But it adds all in the same folder. So no separation between sources
b
I'm out of ideas, then. Can you nut just upgrade to 1.4?
r
Not yet, I am waiting for the 1.4.20 release with a fix for iOS
a
Here's an example of a multiplatform configuration with dokka 0.10: https://github.com/square/okio/blob/f8f1af7f8738813d1fc74191f9923fbd7a3f6fcb/gradle/gradle-mvn-mpp-push.gradle#L5-L42 For my MPP projects, I just leave the
multiplatform
block empty, which works fine: https://github.com/ajalt/clikt/blob/335a5192dad2f5b67c0ba114637c0fcd7166c584/clikt/build.gradle.kts#L87-L91
r
Thank you very much! This will really help me 🙂
👍 1