diff --git a/buildSrc/src/main/kotlin/GradleCommon.kt b/buildSrc/src/main/kotlin/GradleCommon.kt index 86b050c3984..b177a1b5767 100644 --- a/buildSrc/src/main/kotlin/GradleCommon.kt +++ b/buildSrc/src/main/kotlin/GradleCommon.kt @@ -589,7 +589,8 @@ fun Project.addBomCheckTask() { } fun Project.configureDokkaPublication( - shouldLinkGradleApi: Boolean = false + shouldLinkGradleApi: Boolean = false, + configurePublishingToKotlinlang: Boolean = false, ) { if (!kotlinBuildProperties.publishGradlePluginsJavadoc) return @@ -639,6 +640,52 @@ fun Project.configureDokkaPublication( from(dokkaTask.flatMap { it.outputDirectory }) } } + + if (configurePublishingToKotlinlang) { + val latestVariant = GradlePluginVariant.values().last() + val olderVersionsDir = layout.buildDirectory.dir("dokka/kotlinlangDocumentationOld") + + project.dependencies { + // Version is required due to https://github.com/Kotlin/dokka/issues/2812 + "dokkaPlugin"("org.jetbrains.dokka:versioning-plugin:1.7.20") + } + + tasks.register("dokkaKotlinlangDocumentation") { + description = "Generates documentation reference for Kotlinlang" + + dokkaSourceSets { + pluginsMapConfiguration.put( + "org.jetbrains.dokka.base.DokkaBase", + "{ \"templatesDir\": \"${layout.projectDirectory.dir("dokka-template")}\" }" + ) + pluginsMapConfiguration.put( + "org.jetbrains.dokka.versioning.VersioningPlugin", + olderVersionsDir.map { olderVersionsDir -> + "{ \"version\":\"$version\", \"olderVersionsDir\":\"${olderVersionsDir.asFile}\" }" + } + ) + + named(commonSourceSet.name) { + suppress.set(false) + jdkVersion.set(8) + } + + named(latestVariant.sourceSetName) { + dependsOn(commonSourceSet) + suppress.set(false) + jdkVersion.set(8) + + if (shouldLinkGradleApi) { + externalDocumentationLink { + url.set(URL(latestVariant.gradleApiJavadocUrl)) + + addWorkaroundForElementList(latestVariant) + } + } + } + } + } + } } } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index dd24fa3df16..b2eb225a7c6 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -6767,6 +6767,18 @@ + + + + + + + + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts index d47c70884e6..3c869596282 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts @@ -5,7 +5,8 @@ plugins { } configureDokkaPublication( - shouldLinkGradleApi = true + shouldLinkGradleApi = true, + configurePublishingToKotlinlang = true, ) dependencies { diff --git a/libraries/tools/kotlin-gradle-plugin-api/dokka-template/ReadMe.md b/libraries/tools/kotlin-gradle-plugin-api/dokka-template/ReadMe.md new file mode 100644 index 00000000000..970a79da686 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-api/dokka-template/ReadMe.md @@ -0,0 +1,13 @@ +# Dokka's template customization + +To provide unified navigation for all parts of [kotlinlang.org](https://kotlinlang.org/), +the Kotlin Website Team uses this directory to place custom templates in this folder +during the website build time on TeamCity. + +It is not practical to place these templates in the kotlinx-datetime repository because they change from time to time +and aren't related to the plugin's release cycle. + +The folder is defined as a source for custom templates by the templatesDir property through Dokka's plugin configuration. + +[Here](https://kotlin.github.io/dokka/1.7.20/user_guide/output-formats/html/#custom-html-pages), you can +find more about the customization of Dokka's HTML output.