Publish a function to add dynamic readme properties
This commit is contained in:
parent
670a4ca71e
commit
19a604f3b3
@ -8,6 +8,7 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.jetbrains.changelog.ChangelogPlugin
|
import org.jetbrains.changelog.ChangelogPlugin
|
||||||
import org.jetbrains.changelog.ChangelogPluginExtension
|
import org.jetbrains.changelog.ChangelogPluginExtension
|
||||||
|
import org.jetbrains.dokka.gradle.AbstractDokkaTask
|
||||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
import org.jetbrains.dokka.gradle.DokkaTask
|
||||||
import ru.mipt.npm.gradle.internal.*
|
import ru.mipt.npm.gradle.internal.*
|
||||||
@ -200,7 +201,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<DokkaTask> {
|
tasks.withType<AbstractDokkaTask> {
|
||||||
dependsOn(generateReadme)
|
dependsOn(generateReadme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
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")
|
@Deprecated("Use lambda builder instead")
|
||||||
fun feature(id: String, description: String, ref: String? = null, name: String = id) {
|
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) {
|
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(
|
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
||||||
@ -55,14 +55,16 @@ class KScienceReadmeExtension(val project: Project) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val actualizedProperties
|
val actualizedProperties
|
||||||
get() = properties.mapValues { (_, value) ->
|
get() = properties.mapValues { (_, value) -> value() }
|
||||||
value.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun property(key: String, value: Any?) {
|
fun property(key: String, value: Any?) {
|
||||||
properties[key] = { value }
|
properties[key] = { value }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun property(key: String, value: () -> Any?) {
|
||||||
|
properties[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
fun propertyByTemplate(key: String, template: String) {
|
fun propertyByTemplate(key: String, template: String) {
|
||||||
val actual = actualizedProperties
|
val actual = actualizedProperties
|
||||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||||
@ -73,7 +75,7 @@ class KScienceReadmeExtension(val project: Project) {
|
|||||||
fun propertyByTemplate(key: String, template: File) {
|
fun propertyByTemplate(key: String, template: File) {
|
||||||
val actual = actualizedProperties
|
val actual = actualizedProperties
|
||||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||||
additionalFiles.add(template)
|
additionalFiles += template
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user