From 2f7d7fb0979f01a5252a83f7a51db7f3f044b27c Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 8 Sep 2020 19:27:30 +0800 Subject: [PATCH] Add docs --- .../mirai/console/extension/AbstractExtensionPoint.kt | 3 +++ .../kotlin/net/mamoe/mirai/console/extension/Extension.kt | 8 ++++++++ .../mirai/console/extensions/PermissionServiceProvider.kt | 7 +++++-- .../mirai/console/extensions/PostStartupExtension.kt | 8 ++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt index 28560aaf9..c9b0ca7bd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/AbstractExtensionPoint.kt @@ -21,6 +21,9 @@ import kotlin.contracts.contract import kotlin.internal.LowPriorityInOverloadResolution import kotlin.reflect.KClass +/** + * 表示一个扩展点 + */ @ConsoleExperimentalAPI public open class AbstractExtensionPoint( @ConsoleExperimentalAPI diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt index 0c0250174..5eced7d95 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/Extension.kt @@ -13,9 +13,17 @@ import net.mamoe.mirai.console.extensions.PermissionServiceProvider import net.mamoe.mirai.console.extensions.PluginLoaderProvider import net.mamoe.mirai.console.util.ConsoleExperimentalAPI +/** + * 表示一个扩展. + * + * Console 许多不容易通过 + */ @ConsoleExperimentalAPI public interface Extension +/** + * 增加一些函数 (方法)的扩展 + */ @ConsoleExperimentalAPI public interface FunctionExtension : Extension diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PermissionServiceProvider.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PermissionServiceProvider.kt index b50eeefae..b0de62886 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PermissionServiceProvider.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PermissionServiceProvider.kt @@ -4,10 +4,13 @@ import net.mamoe.mirai.console.extension.AbstractExtensionPoint import net.mamoe.mirai.console.extension.SingletonExtension import net.mamoe.mirai.console.permission.ExperimentalPermission import net.mamoe.mirai.console.permission.PermissionService -import net.mamoe.mirai.console.util.ConsoleExperimentalAPI +/** + * [权限服务][PermissionService] 提供器. + * + * 此扩展 + */ @ExperimentalPermission -@ConsoleExperimentalAPI public interface PermissionServiceProvider : SingletonExtension> { public companion object ExtensionPoint : AbstractExtensionPoint(PermissionServiceProvider::class) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt index 1e8508f6d..ee8a97f45 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extensions/PostStartupExtension.kt @@ -12,7 +12,15 @@ package net.mamoe.mirai.console.extensions import net.mamoe.mirai.console.extension.AbstractExtensionPoint import net.mamoe.mirai.console.extension.FunctionExtension +/** + * 在 Console 启动完成后立即在主线程调用的扩展. 用于进行一些必要的延迟初始化. + * + * 这些扩展只会, 且一定会被调用正好一次. + */ public fun interface PostStartupExtension : FunctionExtension { + /** + * 将在 Console 主线程执行. + */ public operator fun invoke() public companion object ExtensionPoint : AbstractExtensionPoint(PostStartupExtension::class)