1.0 Review: documentation and misc improvements

This commit is contained in:
Him188 2020-11-19 09:23:51 +08:00
parent 6dec40c5ea
commit ab5cbcd546
6 changed files with 16 additions and 5 deletions

View File

@ -16,7 +16,10 @@ import net.mamoe.mirai.console.command.CommandManager
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.CompositeCommand
import net.mamoe.mirai.console.command.SimpleCommand
import net.mamoe.mirai.console.command.descriptor.CommandValueArgumentParser.Companion.map
import net.mamoe.mirai.console.command.descriptor.CommandValueArgumentParser.Companion.parse
import net.mamoe.mirai.console.permission.PermissionId
import net.mamoe.mirai.console.permission.PermitteeId
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.message.data.*
import kotlin.contracts.InvocationKind
@ -45,6 +48,9 @@ import kotlin.contracts.contract
* - [User]: [ExistingUserValueArgumentParser]
* - [Contact]: [ExistingContactValueArgumentParser]
*
* - [PermitteeId]: [PermitteeIdValueArgumentParser]
* - [PermissionId]: [PermissionIdValueArgumentParser]
*
*
* @see SimpleCommand 简单指令
* @see CompositeCommand 复合指令
@ -143,6 +149,9 @@ public abstract class AbstractCommandValueArgumentParser<T : Any> : CommandValue
}
}
/**
* @see CommandValueArgumentParser.map
*/
public class MappingCommandValueArgumentParser<T : Any, R : Any>(
private val original: CommandValueArgumentParser<T>,
private val mapper: MappingCommandValueArgumentParser<T, R>.(T) -> R,

View File

@ -31,13 +31,15 @@ import kotlinx.serialization.SerialInfo
* map:
* a: b
* ```
*
* @see net.mamoe.yamlkt.Comment
*/
@SerialInfo
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
public annotation class ValueDescription(
/**
* 将会被 [String.trimIndent] 处理.
* 将会被 [String.trimIndent] 处理
*/
val value: String,
)

View File

@ -23,7 +23,7 @@ package net.mamoe.mirai.console.data
* 将被保存为配置 (YAML 作为示例):
* ```yaml
* AccountPluginData:
* map:
* info:
* a: b
* ```
*

View File

@ -154,7 +154,7 @@ internal abstract class AbstractConcurrentComponentStorage : ComponentStorage {
internal inline fun <T : Extension> ExtensionPoint<T>.useExtensions(block: (extension: T, plugin: Plugin?) -> Unit): Unit =
withExtensions(block)
val instances: MutableMap<ExtensionPoint<*>, MutableSet<ExtensionRegistry<*>>> = ConcurrentHashMap()
private val instances: MutableMap<ExtensionPoint<*>, MutableSet<ExtensionRegistry<*>>> = ConcurrentHashMap()
override fun <T : Extension> contribute(
extensionPoint: ExtensionPoint<T>,
plugin: Plugin,

View File

@ -18,7 +18,7 @@ public abstract class AbstractLoggerController : LoggerController {
protected open fun shouldLog(
priority: LogPriority,
settings: LogPriority
settings: LogPriority,
): Boolean = settings <= priority
protected abstract fun getPriority(identity: String?): LogPriority

View File

@ -17,4 +17,4 @@ package net.mamoe.mirai.console.permission
public class PermissionRegistryConflictException(
public val newInstance: Permission,
public val existingInstance: Permission,
) : Exception("Conflicted Permission registry. new: $newInstance, existing: $existingInstance")
) : Exception("Conflicting Permission registry. new: $newInstance, existing: $existingInstance")