1 import org.jetbrains.dokka.gradle.* 2 import java.net.* 3 4 <lambda>null5plugins { 6 id("org.jetbrains.dokka") 7 } 8 9 val knit_version: String by project 10 private val projetsWithoutDokka = unpublished + "kotlinx-coroutines-bom" + jdk8ObsoleteModule 11 private val coreModuleDocsUrl = "https://kotlinlang.org/api/kotlinx.coroutines/$coreModule/" 12 private val coreModuleDocsPackageList = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list" 13 <lambda>null14configure(subprojects.filterNot { projetsWithoutDokka.contains(it.name) }) { 15 apply(plugin = "org.jetbrains.dokka") 16 configurePathsaver() 17 condigureDokkaSetup() 18 configureExternalLinks() 19 } 20 21 // Setup top-level 'dokkaHtmlMultiModule' with templates <lambda>null22tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") { 23 setupDokkaTemplatesDir(this) 24 } 25 <lambda>null26dependencies { 27 // Add explicit dependency between Dokka and Knit plugin 28 add("dokkaHtmlMultiModulePlugin", "org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version") 29 } 30 31 // Dependencies for Knit processing: Knit plugin to work with Dokka Projectnull32private fun Project.configurePathsaver() { 33 tasks.withType(DokkaTaskPartial::class).configureEach { 34 dependencies { 35 plugins("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version") 36 } 37 } 38 } 39 40 // Configure Dokka setup Projectnull41private fun Project.condigureDokkaSetup() { 42 tasks.withType(DokkaTaskPartial::class).configureEach { 43 suppressInheritedMembers = true 44 setupDokkaTemplatesDir(this) 45 46 dokkaSourceSets.configureEach { 47 jdkVersion = 11 48 includes.from("README.md") 49 noStdlibLink = true 50 51 externalDocumentationLink { 52 url = URL("https://kotlinlang.org/api/latest/jvm/stdlib/") 53 packageListUrl = rootProject.projectDir.toPath().resolve("site/stdlib.package.list").toUri().toURL() 54 } 55 56 // Something suspicious to figure out, probably legacy of earlier days 57 if (!project.isMultiplatform) { 58 dependsOn(project.configurations["compileClasspath"]) 59 } 60 } 61 62 // Source links 63 dokkaSourceSets.configureEach { 64 sourceLink { 65 localDirectory = rootDir 66 remoteUrl = URL("https://github.com/kotlin/kotlinx.coroutines/tree/master") 67 remoteLineSuffix ="#L" 68 } 69 } 70 } 71 } 72 configureExternalLinksnull73private fun Project.configureExternalLinks() { 74 tasks.withType<DokkaTaskPartial>() { 75 dokkaSourceSets.configureEach { 76 externalDocumentationLink { 77 url = URL(coreModuleDocsUrl) 78 packageListUrl = File(coreModuleDocsPackageList).toURI().toURL() 79 } 80 } 81 } 82 } 83 84 /** 85 * Setups Dokka templates. While this directory is empty in our repository, 86 * 'kotlinlang' build pipeline adds templates there when preparing our documentation 87 * to be published on kotlinlang. 88 * 89 * See: 90 * - Template setup: https://github.com/JetBrains/kotlin-web-site/blob/master/.teamcity/builds/apiReferences/kotlinx/coroutines/KotlinxCoroutinesPrepareDokkaTemplates.kt 91 * - Templates repository: https://github.com/JetBrains/kotlin-web-site/tree/master/dokka-templates 92 */ Projectnull93private fun Project.setupDokkaTemplatesDir(dokkaTask: AbstractDokkaTask) { 94 dokkaTask.pluginsMapConfiguration = mapOf( 95 "org.jetbrains.dokka.base.DokkaBase" to """{ "templatesDir" : "${ 96 project.rootProject.projectDir.toString().replace('\\', '/') 97 }/dokka-templates" }""" 98 ) 99 } 100