mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add docs
This commit is contained in:
parent
f82d01e606
commit
c87e8b07df
@ -21,6 +21,7 @@ kotlin {
|
||||
languageSettings.useExperimentalAnnotation("kotlin.OptIn")
|
||||
languageSettings.progressiveMode = true
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||
|
@ -12,23 +12,39 @@
|
||||
package net.mamoe.mirai.console.setting
|
||||
|
||||
import kotlinx.serialization.KSerializer
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
|
||||
/**
|
||||
* 在配置文件和图像界面中保存的名称.
|
||||
*/
|
||||
typealias SerialName = kotlinx.serialization.SerialName
|
||||
|
||||
/**
|
||||
* 在配置文件和图像界面中显示的说明.
|
||||
*/
|
||||
typealias Comment = net.mamoe.yamlkt.Comment
|
||||
|
||||
/**
|
||||
* 配置的基类. 所有配置必须拥有一个无参构造器, 以用于在 [MutableList] 与 [MutableMap] 中动态识别类型
|
||||
*/
|
||||
@Suppress("EXPOSED_SUPER_CLASS")
|
||||
abstract class Setting : SettingImpl() {
|
||||
/**
|
||||
* 这个配置的名称, 仅对于顶层配置有效.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
open val serialName: String
|
||||
get() = this::class.findAnnotation<SerialName>()?.value
|
||||
?: this::class.qualifiedName
|
||||
?: error("Names should be assigned to anonymous classes manually by overriding serialName")
|
||||
|
||||
|
||||
/**
|
||||
* 提供属性委托, 并添加这个对象的自动保存跟踪.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
operator fun <T : Any> Value<T>.provideDelegate(
|
||||
thisRef: Setting,
|
||||
|
Loading…
Reference in New Issue
Block a user