diff --git a/nonebot/config.py b/nonebot/config.py index 5fad11be..f2e1d0a0 100644 --- a/nonebot/config.py +++ b/nonebot/config.py @@ -4,6 +4,10 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及 [`python-dotenv`](https://saurabh-kumar.com/python-dotenv/) 来读取配置。 配置项需符合特殊格式或 json 序列化格式。详情见 [`pydantic Field Type`](https://pydantic-docs.helpmanual.io/usage/types/) 文档。 + +FrontMatter: + sidebar_position: 1 + description: nonebot.config 模块 """ import os from pathlib import Path diff --git a/nonebot/consts.py b/nonebot/consts.py index 11e3feaa..0d332e6d 100644 --- a/nonebot/consts.py +++ b/nonebot/consts.py @@ -1,20 +1,27 @@ +""" +FrontMatter: + sidebar_position: 9 + description: nonebot.consts 模块 +""" +from typing_extensions import Literal + # used by Matcher -RECEIVE_KEY = "_receive_{id}" -LAST_RECEIVE_KEY = "_last_receive" -ARG_KEY = "{key}" -REJECT_TARGET = "_current_target" -REJECT_CACHE_TARGET = "_next_target" +RECEIVE_KEY: Literal["_receive_{id}"] = "_receive_{id}" +LAST_RECEIVE_KEY: Literal["_last_receive"] = "_last_receive" +ARG_KEY: Literal["{key}"] = "{key}" +REJECT_TARGET: Literal["_current_target"] = "_current_target" +REJECT_CACHE_TARGET: Literal["_next_target"] = "_next_target" # used by Rule -PREFIX_KEY = "_prefix" +PREFIX_KEY: Literal["_prefix"] = "_prefix" -CMD_KEY = "command" -RAW_CMD_KEY = "raw_command" -CMD_ARG_KEY = "command_arg" +CMD_KEY: Literal["command"] = "command" +RAW_CMD_KEY: Literal["raw_command"] = "raw_command" +CMD_ARG_KEY: Literal["command_arg"] = "command_arg" -SHELL_ARGS = "_args" -SHELL_ARGV = "_argv" +SHELL_ARGS: Literal["_args"] = "_args" +SHELL_ARGV: Literal["_argv"] = "_argv" -REGEX_MATCHED = "_matched" -REGEX_GROUP = "_matched_groups" -REGEX_DICT = "_matched_dict" +REGEX_MATCHED: Literal["_matched"] = "_matched" +REGEX_GROUP: Literal["_matched_groups"] = "_matched_groups" +REGEX_DICT: Literal["_matched_dict"] = "_matched_dict" diff --git a/nonebot/exception.py b/nonebot/exception.py index eb489a73..79b9d5b2 100644 --- a/nonebot/exception.py +++ b/nonebot/exception.py @@ -3,6 +3,10 @@ 下列文档中的异常是所有 NoneBot 运行时可能会抛出的。 这些异常并非所有需要用户处理,在 NoneBot 内部运行时被捕获,并进行对应操作。 + +FrontMatter: + sidebar_position: 10 + description: nonebot.exception 模块 """ from typing import Any, Optional diff --git a/nonebot/log.py b/nonebot/log.py index 08f54894..959f05f7 100644 --- a/nonebot/log.py +++ b/nonebot/log.py @@ -6,6 +6,10 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。 自定义 logger 请参考 [`loguru`][loguru] 文档。 [loguru]: https://github.com/Delgan/loguru + +FrontMatter: + sidebar_position: 7 + description: nonebot.log 模块 """ import sys @@ -28,9 +32,9 @@ NoneBot 日志记录器对象。 默认信息: - - 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s` - - 等级: `INFO` ,根据 `config.log_level` 配置改变 - - 输出: 输出至 stdout +- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s` +- 等级: `INFO` ,根据 `config.log_level` 配置改变 +- 输出: 输出至 stdout 用法: ```python diff --git a/nonebot/matcher.py b/nonebot/matcher.py index e1de199e..d7a614c3 100644 --- a/nonebot/matcher.py +++ b/nonebot/matcher.py @@ -1,7 +1,11 @@ """ ## 事件响应器 -该模块实现事件响应器的创建与运行,并提供一些快捷方法来帮助用户更好的与机器人进行对话 。 +该模块实现事件响应器的创建与运行,并提供一些快捷方法来帮助用户更好的与机器人进行对话。 + +FrontMatter: + sidebar_position: 3 + description: nonebot.matcher 模块 """ from types import ModuleType diff --git a/nonebot/message.py b/nonebot/message.py index 6a927558..2557580b 100644 --- a/nonebot/message.py +++ b/nonebot/message.py @@ -2,6 +2,10 @@ ## 事件处理 NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供了多个插槽以进行事件的预处理等。 + +FrontMatter: + sidebar_position: 2 + description: nonebot.message 模块 """ import asyncio diff --git a/nonebot/params.py b/nonebot/params.py index ad1d3e63..2f6cef4c 100644 --- a/nonebot/params.py +++ b/nonebot/params.py @@ -1,3 +1,9 @@ +""" +FrontMatter: + sidebar_position: 4 + description: nonebot.params 模块 +""" + import asyncio import inspect import warnings diff --git a/nonebot/permission.py b/nonebot/permission.py index f3fa8253..3079f47e 100644 --- a/nonebot/permission.py +++ b/nonebot/permission.py @@ -3,9 +3,9 @@ 每个 `Matcher` 拥有一个 `Permission` ,其中是 `PermissionChecker` 的集合,只要有一个 `PermissionChecker` 检查结果为 `True` 时就会继续运行。 -:::tip 提示 -`PermissionChecker` 既可以是 async function 也可以是 sync function -::: +FrontMatter: + sidebar_position: 6 + description: nonebot.permission 模块 """ import asyncio diff --git a/nonebot/rule.py b/nonebot/rule.py index 5a3c446c..8decd8c5 100644 --- a/nonebot/rule.py +++ b/nonebot/rule.py @@ -3,9 +3,9 @@ 每个事件响应器 `Matcher` 拥有一个匹配规则 `Rule` ,其中是 `RuleChecker` 的集合,只有当所有 `RuleChecker` 检查结果为 `True` 时继续运行。 -:::tip 提示 -`RuleChecker` 既可以是 async function 也可以是 sync function -::: +FrontMatter: + sidebar_position: 5 + description: nonebot.rule 模块 """ import re diff --git a/nonebot/typing.py b/nonebot/typing.py index b93f5108..a92b79e9 100644 --- a/nonebot/typing.py +++ b/nonebot/typing.py @@ -6,6 +6,10 @@ 除了 Python 内置的类型,下面还出现了如下 NoneBot 自定类型,实际上它们是 Python 内置类型的别名。 以下类型均可从 nonebot.typing 模块导入。 + +FrontMatter: + sidebar_position: 11 + description: nonebot.typing 模块 """ from typing import ( TYPE_CHECKING, diff --git a/nonebot/utils.py b/nonebot/utils.py index 8c621df6..3cafa155 100644 --- a/nonebot/utils.py +++ b/nonebot/utils.py @@ -1,3 +1,9 @@ +""" +FrontMatter: + sidebar_position: 8 + description: nonebot.utils 模块 +""" + import re import json import asyncio diff --git a/website/docs/api/adapters/_category_.json b/website/docs/api/adapters/_category_.json new file mode 100644 index 00000000..a2253e3d --- /dev/null +++ b/website/docs/api/adapters/_category_.json @@ -0,0 +1,3 @@ +{ + "position": 15 +} diff --git a/website/docs/api/dependencies/_category_.json b/website/docs/api/dependencies/_category_.json new file mode 100644 index 00000000..6bd1772a --- /dev/null +++ b/website/docs/api/dependencies/_category_.json @@ -0,0 +1,3 @@ +{ + "position": 13 +} diff --git a/website/docs/api/drivers/_category_.json b/website/docs/api/drivers/_category_.json new file mode 100644 index 00000000..3714fde8 --- /dev/null +++ b/website/docs/api/drivers/_category_.json @@ -0,0 +1,3 @@ +{ + "position": 14 +} diff --git a/website/docs/api/plugin/_category_.json b/website/docs/api/plugin/_category_.json index 455b8e49..14e3de02 100644 --- a/website/docs/api/plugin/_category_.json +++ b/website/docs/api/plugin/_category_.json @@ -1,3 +1,3 @@ { - "position": 20 + "position": 12 }