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

View File

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

View File

@ -23,7 +23,7 @@ package net.mamoe.mirai.console.data
* 将被保存为配置 (YAML 作为示例): * 将被保存为配置 (YAML 作为示例):
* ```yaml * ```yaml
* AccountPluginData: * AccountPluginData:
* map: * info:
* a: b * 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 = internal inline fun <T : Extension> ExtensionPoint<T>.useExtensions(block: (extension: T, plugin: Plugin?) -> Unit): Unit =
withExtensions(block) withExtensions(block)
val instances: MutableMap<ExtensionPoint<*>, MutableSet<ExtensionRegistry<*>>> = ConcurrentHashMap() private val instances: MutableMap<ExtensionPoint<*>, MutableSet<ExtensionRegistry<*>>> = ConcurrentHashMap()
override fun <T : Extension> contribute( override fun <T : Extension> contribute(
extensionPoint: ExtensionPoint<T>, extensionPoint: ExtensionPoint<T>,
plugin: Plugin, plugin: Plugin,

View File

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

View File

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