Publish a function to add dynamic readme properties #15

Merged
CommanderTvis merged 1 commits from commandertvis/property into dev 2021-06-19 10:52:34 +03:00
3 changed files with 11 additions and 8 deletions

0
gradlew vendored Normal file → Executable file
View File

View File

@ -8,6 +8,7 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import ru.mipt.npm.gradle.internal.*
@ -200,7 +201,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
}
}
tasks.withType<DokkaTask> {
tasks.withType<AbstractDokkaTask> {
dependsOn(generateReadme)
}

View File

@ -36,15 +36,15 @@ class KScienceReadmeExtension(val project: Project) {
data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
val features = ArrayList<Feature>()
val features: MutableList<Feature> = ArrayList()
@Deprecated("Use lambda builder instead")
fun feature(id: String, description: String, ref: String? = null, name: String = id) {
features.add(Feature(id, description, ref, name))
features += Feature(id, description, ref, name)
}
fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
features.add(Feature(id, description(), ref, name))
features += Feature(id, description(), ref, name)
}
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
@ -55,14 +55,16 @@ class KScienceReadmeExtension(val project: Project) {
)
val actualizedProperties
get() = properties.mapValues { (_, value) ->
value.invoke()
}
get() = properties.mapValues { (_, value) -> value() }
fun property(key: String, value: Any?) {
properties[key] = { value }
}
fun property(key: String, value: () -> Any?) {
properties[key] = value
}
fun propertyByTemplate(key: String, template: String) {
val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
@ -73,7 +75,7 @@ class KScienceReadmeExtension(val project: Project) {
fun propertyByTemplate(key: String, template: File) {
val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
additionalFiles.add(template)
additionalFiles += template
}
/**