-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdokka-conventions.gradle.kts
94 lines (81 loc) · 2.83 KB
/
dokka-conventions.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import org.gradle.api.Project
import org.jetbrains.dokka.gradle.*
import java.io.File
import java.net.*
plugins {
id("org.jetbrains.dokka")
}
val knit_version: String by project
private val projetsWithoutDokka = unpublished + "kotlinx-coroutines-bom" + jdk8ObsoleteModule
private val coreModuleDocsUrl = "https://kotlinlang.org/api/kotlinx.coroutines/$coreModule/"
private val coreModuleDocsPackageList = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list"
configure(subprojects.filterNot { projetsWithoutDokka.contains(it.name) }) {
apply(plugin = "org.jetbrains.dokka")
configurePathsaver()
condigureDokkaSetup()
configureExternalLinks()
}
// For top-level multimodule collection
dokka {
setupDokkaTemplatesDir()
}
dependencies {
dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
subprojects.forEach {
if (it.name !in projetsWithoutDokka) {
dokka(it)
}
}
}
// Dependencies for Knit processing: Knit plugin to work with Dokka
private fun Project.configurePathsaver() {
dependencies {
dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
}
}
// Configure Dokka setup
private fun Project.condigureDokkaSetup() {
dokka {
dokkaPublications.configureEach {
suppressInheritedMembers = true
}
setupDokkaTemplatesDir()
dokkaSourceSets.configureEach {
jdkVersion = 11
includes.from("README.md")
sourceLink {
localDirectory = rootDir
remoteUrl = URI("https://github.com/kotlin/kotlinx.coroutines/tree/master")
remoteLineSuffix = "#L"
}
}
// TODO: WA for KT-71784
dokkaSourceSets.matching { it.name == "commonMain" }.configureEach {
suppress.set(true)
}
}
}
private fun Project.configureExternalLinks() {
dokka {
dokkaSourceSets.configureEach {
externalDocumentationLinks.register("kotlinx-coroutines-core") {
url = URI(coreModuleDocsUrl)
packageListUrl = File(coreModuleDocsPackageList).toURI()
}
}
}
}
/**
* Setups Dokka templates. While this directory is empty in our repository,
* 'kotlinlang' build pipeline adds templates there when preparing our documentation
* to be published on kotlinlang.
*
* See:
* - Template setup: https://github.com/JetBrains/kotlin-web-site/blob/master/.teamcity/builds/apiReferences/kotlinx/coroutines/KotlinxCoroutinesPrepareDokkaTemplates.kt
* - Templates repository: https://github.com/JetBrains/kotlin-web-site/tree/master/dokka-templates
*/
private fun DokkaExtension.setupDokkaTemplatesDir() {
pluginsConfiguration.html {
templatesDir = file(rootDir.toString().replace('\\', '/') + "/dokka-templates")
}
}