This commit is contained in:
Alexander Nozik 2023-08-21 18:26:17 +03:00
parent 8a864f97a3
commit c249dc5ae4
3 changed files with 33 additions and 25 deletions

View File

@ -1,25 +1,25 @@
[versions] [versions]
tools = "0.14.9-kotlin-1.9.0" tools = "0.14.10-kotlin-1.9.0"
kotlin = "1.9.0" kotlin = "1.9.0"
atomicfu = "0.20.2" atomicfu = "0.22.0"
binary-compatibility-validator = "0.13.1" binary-compatibility-validator = "0.13.2"
changelog = "2.0.0" changelog = "2.1.2"
dokka = "1.8.10" dokka = "1.8.20"
kotlin-jupyter = "0.11.0-360" kotlin-jupyter = "0.12.0-43"
kotlinx-benchmark = "0.4.7" kotlinx-benchmark = "0.4.9"
kotlinx-cli = "0.3.5" kotlinx-cli = "0.3.5"
kotlinx-coroutines = "1.7.2" kotlinx-coroutines = "1.7.3"
kotlinx-datetime = "0.4.0" kotlinx-datetime = "0.4.0"
kotlinx-html = "0.8.0" kotlinx-html = "0.9.1"
kotlinx-knit = "0.4.0" kotlinx-knit = "0.4.0"
kotlinx-nodejs = "0.0.7" kotlinx-nodejs = "0.0.7"
kotlinx-serialization = "1.5.1" kotlinx-serialization = "1.5.1"
ktor = "2.3.0" ktor = "2.3.3"
xmlutil = "0.86.0" xmlutil = "0.86.1"
yamlkt = "0.13.0" yamlkt = "0.13.0"
jsBom = "1.0.0-pre.546" jsBom = "1.0.0-pre.618"
junit = "5.9.3" junit = "5.9.3"
compose = "1.4.0" compose = "1.5.0-rc01"
logback = "1.4.7" logback = "1.4.7"
[libraries] [libraries]

View File

@ -205,17 +205,18 @@ public open class KScienceProjectPlugin : Plugin<Project> {
val modulesString = buildString { val modulesString = buildString {
subprojects.forEach { subproject -> subprojects.forEach { subproject ->
// val name = subproject.name // val name = subproject.name
subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext -> subproject.extensions.findByType<KScienceReadmeExtension>()
val path = subproject.path.replaceFirst(":", "").replace(":", "/") ?.let { ext: KScienceReadmeExtension ->
appendLine("\n### [$path]($path)") val path = subproject.path.replaceFirst(":", "").replace(":", "/")
appendLine("> ${ext.description}") appendLine("\n### [$path]($path)")
appendLine(">\n> **Maturity**: ${ext.maturity}") ext.description?.let { appendLine("> ${ext.description}") }
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/") appendLine(">\n> **Maturity**: ${ext.maturity}")
if (featureString.isNotBlank()) { val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
appendLine(">\n> **Features:**") if (featureString.isNotBlank()) {
appendLine(featureString) appendLine(">\n> **Features:**")
appendLine(featureString)
}
} }
}
} }
} }

View File

@ -10,6 +10,7 @@ import kotlinx.html.stream.createHTML
import kotlinx.validation.ApiValidationExtension import kotlinx.validation.ApiValidationExtension
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.kotlin.dsl.findByType import org.gradle.kotlin.dsl.findByType
import org.intellij.lang.annotations.Language
import java.io.File import java.io.File
import java.io.StringWriter import java.io.StringWriter
import kotlin.collections.component1 import kotlin.collections.component1
@ -32,7 +33,8 @@ private fun Template.processToString(args: Map<String, Any?>): String {
public class KScienceReadmeExtension(public val project: Project) { public class KScienceReadmeExtension(public val project: Project) {
public var description: String = project.description ?: "" public var description: String? = null
get() = field ?: project.description
public var maturity: Maturity = Maturity.EXPERIMENTAL public var maturity: Maturity = Maturity.EXPERIMENTAL
set(value) { set(value) {
@ -93,7 +95,12 @@ public class KScienceReadmeExtension(public val project: Project) {
/** /**
* A plain readme feature with description * A plain readme feature with description
*/ */
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) { public fun feature(
id: String,
@Language("File") ref: String? = null,
name: String = id,
description: () -> String,
) {
features += Feature(id, description(), ref, name) features += Feature(id, description(), ref, name)
} }