From 713a129fabe882b7a96e2ad9706371058e49fc09 Mon Sep 17 00:00:00 2001 From: Piyush Mor Date: Fri, 15 Nov 2019 23:41:36 +0100 Subject: [PATCH] use Dokka for javadocs #82 Signed-off-by: Piyush Mor --- build.gradle.kts | 18 ++++++++++++++---- src/commonMain/kotlin/mu/KotlinLogging.kt | 2 ++ src/jsMain/kotlin/mu/KotlinLogging.kt | 2 ++ src/jvmMain/kotlin/mu/KLogger.kt | 2 ++ src/jvmMain/kotlin/mu/KLogging.kt | 2 ++ src/jvmMain/kotlin/mu/KotlinLogging.kt | 2 ++ src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt | 18 ++++++++++++------ 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 646433ee..174e712e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,10 @@ -import java.util.* +import org.jetbrains.dokka.gradle.DokkaTask +import java.util.Date plugins { kotlin("multiplatform") version "1.3.50" id("com.jfrog.bintray") version "1.8.4" + id("org.jetbrains.dokka") version "0.10.0" `maven-publish` `java-library` //todo: ask whether we need javadoc at all as it is always empty } @@ -16,15 +18,23 @@ version = "1.6.27" repositories { mavenCentral() + jcenter() } + + tasks { register("javadocJar") { - val javadocTask = getByName("javadoc") - from(javadocTask.destinationDir) - dependsOn(javadocTask) + val dokkaTask = getByName("dokka") + from(dokkaTask.outputDirectory) + dependsOn(dokkaTask) archiveClassifier.set("javadoc") } + dokka { + outputFormat = "javadoc" + outputDirectory = "$buildDir/dokka" + + } } kotlin { diff --git a/src/commonMain/kotlin/mu/KotlinLogging.kt b/src/commonMain/kotlin/mu/KotlinLogging.kt index 9a7f0722..3bce9528 100644 --- a/src/commonMain/kotlin/mu/KotlinLogging.kt +++ b/src/commonMain/kotlin/mu/KotlinLogging.kt @@ -4,7 +4,9 @@ package mu expect object KotlinLogging { /** * This method allow defining the logger in a file in the following way: + * ``` * val logger = KotlinLogging.logger {} + * ``` */ fun logger(func: () -> Unit): KLogger diff --git a/src/jsMain/kotlin/mu/KotlinLogging.kt b/src/jsMain/kotlin/mu/KotlinLogging.kt index d807bfb5..b5de0738 100644 --- a/src/jsMain/kotlin/mu/KotlinLogging.kt +++ b/src/jsMain/kotlin/mu/KotlinLogging.kt @@ -6,7 +6,9 @@ import mu.internal.KLoggerJS actual object KotlinLogging { /** * This method allow defining the logger in a file in the following way: + * ``` * val logger = KotlinLogging.logger {} + * ``` */ actual fun logger(func: () -> Unit): KLogger = KLoggerJS(func::class.js.name) diff --git a/src/jvmMain/kotlin/mu/KLogger.kt b/src/jvmMain/kotlin/mu/KLogger.kt index f65f35b2..80a842d3 100644 --- a/src/jvmMain/kotlin/mu/KLogger.kt +++ b/src/jvmMain/kotlin/mu/KLogger.kt @@ -5,7 +5,9 @@ import org.slf4j.Logger /** * An extension for [Logger] with Lazy message evaluation * example: + * ``` * logger.info{"this is $lazy evaluated string"} + *``` */ actual interface KLogger : Logger { diff --git a/src/jvmMain/kotlin/mu/KLogging.kt b/src/jvmMain/kotlin/mu/KLogging.kt index 8096bfa9..7aae8c12 100644 --- a/src/jvmMain/kotlin/mu/KLogging.kt +++ b/src/jvmMain/kotlin/mu/KLogging.kt @@ -5,12 +5,14 @@ import mu.internal.KLoggerFactory /** * A class with logging capabilities * usage example: + * ``` * class ClassWithLogging { * companion object: KLogging() * fun test() { * logger.info{"test ClassWithLogging"} * } * } + * ``` */ open class KLogging : KLoggable { override val logger: KLogger = logger() diff --git a/src/jvmMain/kotlin/mu/KotlinLogging.kt b/src/jvmMain/kotlin/mu/KotlinLogging.kt index ed73e8d3..f8780f2d 100644 --- a/src/jvmMain/kotlin/mu/KotlinLogging.kt +++ b/src/jvmMain/kotlin/mu/KotlinLogging.kt @@ -7,7 +7,9 @@ import org.slf4j.Logger actual object KotlinLogging { /** * This method allow defining the logger in a file in the following way: + * ``` * val logger = KotlinLogging.logger {} + * ``` */ actual fun logger(func: () -> Unit): KLogger = KLoggerFactory.logger(func) diff --git a/src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt b/src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt index cc7dcf75..71ce44ba 100644 --- a/src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt +++ b/src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt @@ -4,18 +4,22 @@ import org.slf4j.MDC /** * Use a pair in MDC context. Example: - * `withLoggingContext("userId" to userId) { + * ``` + * withLoggingContext("userId" to userId) { * doSomething() - * }` + * } + * ``` */ inline fun withLoggingContext(pair: Pair, body: () -> T): T = MDC.putCloseable(pair.first, pair.second).use { body() } /** * Use a vary number of pairs in MDC context. Example: - * `withLoggingContext("userId" to userId) { + * ``` + * withLoggingContext("userId" to userId) { * doSomething() - * }` + * } + * ``` */ inline fun withLoggingContext(vararg pair: Pair, body: () -> T): T { try { @@ -28,9 +32,11 @@ inline fun withLoggingContext(vararg pair: Pair, body: () -> /** * Use a map in MDC context. Example: - * `withLoggingContext(mapOf("userId" to userId)) { + * ``` + * withLoggingContext(mapOf("userId" to userId)) { * doSomething() - * }` + * } + * ``` */ inline fun withLoggingContext(map: Map, body: () -> T): T { try {