diff --git a/dokka.gradle b/dokka.gradle index 3b006a7..dea94a8 100644 --- a/dokka.gradle +++ b/dokka.gradle @@ -1,6 +1,4 @@ -dokka { - outputFormat = 'html' - +dokkaHtml { switch (true) { case project.hasProperty("DOKKA_PATH"): outputDirectory = project.property("DOKKA_PATH").toString() @@ -10,33 +8,30 @@ dokka { break } - multiplatform { - global { - perPackageOption { - prefix = "dev.inmo" - skipDeprecated = true - includeNonPublic = true - reportUndocumented = true - } + dokkaSourceSets { + configureEach { + skipDeprecated.set(true) + includeNonPublic.set(true) + reportUndocumented.set(true) sourceLink { - path = "./" - url = "https://github.com/InsanusMokrassar/krontab/blob/master/" - lineSuffix = "#L" + localDirectory.set(file("./")) + remoteUrl.set(new URL("https://github.com/InsanusMokrassar/krontab/blob/master/")) + remoteLineSuffix.set("#L") } } - common { - targets = ["JVM", "JS"] + named("commonMain") { sourceRoot { path = "src/commonMain" } } - js { - targets = ["JS"] - sourceRoot { path = "src/jsMain" } - } - jvm { - targets = ["JVM"] - sourceRoot { path = "src/jvmMain" } - } + +// +// named("jsMain") { +// sourceRoot { path = "src/jsMain" } +// } +// +// named("jvmMain") { +// sourceRoot { path = "src/jvmMain" } +// } } } diff --git a/gradle.properties b/gradle.properties index 9b086d5..83a5763 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ kotlin.incremental.multiplatform=true kotlin_version=1.4.20 kotlin_coroutines_version=1.4.2 -dokka_version=0.10.1 +dokka_version=1.4.20 klockVersion=2.0.1 diff --git a/src/commonMain/kotlin/dev/inmo/krontab/collection/CollectionKronScheduler.kt b/src/commonMain/kotlin/dev/inmo/krontab/collection/CollectionKronScheduler.kt index e819d16..2c6ad20 100644 --- a/src/commonMain/kotlin/dev/inmo/krontab/collection/CollectionKronScheduler.kt +++ b/src/commonMain/kotlin/dev/inmo/krontab/collection/CollectionKronScheduler.kt @@ -3,29 +3,42 @@ package dev.inmo.krontab.collection import com.soywiz.klock.DateTime import dev.inmo.krontab.KronScheduler import dev.inmo.krontab.anyCronDateTime +import dev.inmo.krontab.internal.* import dev.inmo.krontab.internal.CronDateTimeScheduler +import dev.inmo.krontab.internal.merge import dev.inmo.krontab.internal.toNearDateTime +/** + * This scheduler will be useful in case you want to unite several different [KronScheduler]s + */ data class CollectionKronScheduler private constructor( internal val schedulers: MutableList ) : KronScheduler { internal constructor(schedulers: List) : this(schedulers.toMutableList()) internal constructor() : this(mutableListOf()) + /** + * Add [kronScheduler] into its [schedulers] list + * + * * When [kronScheduler] is [CronDateTimeScheduler] it will merge all [CronDateTimeScheduler]s from [schedulers] list + * and this [kronScheduler] using [merge] function + * * When [kronScheduler] is [CollectionKronScheduler] it this instance will include all [kronScheduler] + * [schedulers] + * * Otherwise [kronScheduler] will be added to [schedulers] list + */ fun include(kronScheduler: KronScheduler) { when (kronScheduler) { is CronDateTimeScheduler -> { - val resultCronDateTimes = kronScheduler.cronDateTimes.toMutableList() + val resultCronDateTimes = mutableListOf(kronScheduler) schedulers.removeAll { if (it is CronDateTimeScheduler) { - resultCronDateTimes.addAll(it.cronDateTimes) - true + resultCronDateTimes.add(it) } else { false } } schedulers.add( - CronDateTimeScheduler(resultCronDateTimes.distinct()) + merge(resultCronDateTimes) ) } is CollectionKronScheduler -> kronScheduler.schedulers.forEach { diff --git a/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt b/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt index c178620..5d83a3c 100644 --- a/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt +++ b/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt @@ -30,3 +30,11 @@ internal data class CronDateTimeScheduler internal constructor( } } +/** + * @return New instance of [CronDateTimeScheduler] with all unique [CronDateTimeScheduler.cronDateTimes] of + * [kronDateTimeSchedulers] included + */ +@Suppress("NOTHING_TO_INLINE") +internal inline fun merge(kronDateTimeSchedulers: List) = CronDateTimeScheduler( + kronDateTimeSchedulers.flatMap { it.cronDateTimes }.distinct() +)