Skip to content

Commit

Permalink
Render kotlin-reflect library documentation in a separate module
Browse files Browse the repository at this point in the history
(cherry picked from commit ba6732a)
  • Loading branch information
ilya-g committed Apr 27, 2023
1 parent 442f3f8 commit 5e1e4ec
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
18 changes: 18 additions & 0 deletions libraries/reflect/Module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Module kotlin-reflect

## Kotlin JVM reflection extensions

The library provides the runtime component that enables full support of the reflection features in `kotlin.reflect` package
and extensions for the reflection types.

It's provided as an optional artifact separate from the standard library to reduce the required size of the runtime dependencies
for applications that do not use reflection features.

# Package kotlin.reflect.full

Extensions for [Kotlin reflection](https://kotlinlang.org/docs/reference/reflection.html) types like [kotlin.reflect.KClass], [kotlin.reflect.KType], and others.

# Package kotlin.reflect.jvm

Extensions for conversion between [Kotlin reflection](https://kotlinlang.org/docs/reference/reflection.html) and
Java reflection types and other JVM-specific extensions.
55 changes: 50 additions & 5 deletions libraries/tools/kotlin-stdlib-docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) =
"kotlin.native.internal",
"kotlin.jvm.functions",
"kotlin.coroutines.jvm.internal",
"kotlin.reflect.jvm.internal"
)

var kotlinLanguageVersion = version
Expand Down Expand Up @@ -114,7 +113,6 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) =

sourceRoots.from("$kotlin_stdlib_dir/jvm/src")

sourceRoots.from("$kotlin_root/core/reflection.jvm/src")
sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/annotations")
sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/JvmClassMapping.kt")
sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/PurelyImplements.kt")
Expand Down Expand Up @@ -220,6 +218,51 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) =
}
}

fun createKotlinReflectVersionedDocTask(version: String, isLatest: Boolean) =
tasks.register<DokkaTaskPartial>("kotlin-reflect_" + version + (if (isLatest) "_latest" else "")) {
dependsOn(prepare)

val kotlinReflectIncludeMd = file("$kotlin_root/libraries/reflect/Module.md")

val kotlinReflectClasspath = fileTree("$kotlin_libs/kotlin-reflect")

val kotlinLanguageVersion = version

moduleName.set("kotlin-reflect")

val moduleDirName = "kotlin-reflect"
with(pluginsMapConfiguration) {
put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "$templatesDir" }""")
put("org.jetbrains.dokka.versioning.VersioningPlugin", """{ "version": "$version" }""")
}
if (isLatest) {
outputDirectory.set(file("$outputDirPartial/latest").resolve(moduleDirName))
} else {
outputDirectory.set(file("$outputDirPartial/previous").resolve(moduleDirName).resolve(version))
pluginsMapConfiguration.put("org.jetbrains.dokka.kotlinlang.VersionFilterPlugin", """{ "targetVersion": "$version" }""")
}

dokkaSourceSets {
register("jvm") {
jdkVersion.set(8)
platform.set(Platform.jvm)
classpath.setFrom(kotlinReflectClasspath)

displayName.set("JVM")
sourceRoots.from("$kotlin_root/core/reflection.jvm/src")

skipDeprecated.set(false)
includes.from(kotlinReflectIncludeMd)
languageVersion.set(kotlinLanguageVersion)
noStdlibLink.set(true)
perPackageOption("kotlin.reflect.jvm.internal") {
suppress.set(true)
}
sourceLinksFromRoot()
}
}
}

fun createKotlinTestVersionedDocTask(version: String, isLatest: Boolean) =
tasks.register<DokkaTaskPartial>("kotlin-test_" + version + (if (isLatest) "_latest" else "")) {
dependsOn(prepare)
Expand Down Expand Up @@ -413,15 +456,17 @@ gradle.projectsEvaluated {
val buildLatestVersion by tasks.registering

val latestStdlib = createStdLibVersionedDocTask(latestVersion, true)
val latestReflect = createKotlinReflectVersionedDocTask(latestVersion, true)
val latestTest = createKotlinTestVersionedDocTask(latestVersion, true)
val latestAll = createAllLibsVersionedDocTask(latestVersion, true, latestStdlib, latestTest)
val latestAll = createAllLibsVersionedDocTask(latestVersion, true, latestStdlib, latestReflect, latestTest)

buildLatestVersion.configure { dependsOn(latestStdlib, latestTest, latestAll) }
buildLatestVersion.configure { dependsOn(latestStdlib, latestTest, latestReflect, latestAll) }

versions.forEach { version ->
val versionStdlib = createStdLibVersionedDocTask(version, false)
val versionReflect = createKotlinReflectVersionedDocTask(version, false)
val versionTest = createKotlinTestVersionedDocTask(version, false)
val versionAll = createAllLibsVersionedDocTask(version, isLatest = false, versionStdlib, versionTest)
val versionAll = createAllLibsVersionedDocTask(version, isLatest = false, versionStdlib, versionReflect, versionTest)
if (version != latestVersion) {
latestAll.configure { dependsOn(versionAll) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ val modules = listOf(
"kotlin-stdlib-jdk7",
"kotlin-stdlib-jdk8",
"kotlin-stdlib-js",
"kotlin-reflect",
"kotlin-test",
"kotlin-test-js",
"kotlin-test-junit5",
Expand Down

0 comments on commit 5e1e4ec

Please sign in to comment.