使用 markdown 格式的强调语法

This commit is contained in:
hemengyang
2022-01-12 18:19:21 +08:00
parent 0099364838
commit 4ba1a09fb7
25 changed files with 536 additions and 536 deletions

View File

@ -2,7 +2,7 @@
协议适配基类
============
各协议请继承以下基类,并使用 ``driver.register_adapter`` 注册适配器
各协议请继承以下基类,并使用 `driver.register_adapter` 注册适配器
"""
from typing import Iterable

View File

@ -63,11 +63,11 @@ class Adapter(abc.ABC):
@abc.abstractmethod
async def _call_api(self, bot: Bot, api: str, **data) -> Any:
"""
``adapter`` 实际调用 api 的逻辑实现函数,实现该方法以调用 api。
`adapter` 实际调用 api 的逻辑实现函数,实现该方法以调用 api。
:参数:
* ``api: str``: API 名称
* ``**data``: API 数据
* `api: str`: API 名称
* `**data`: API 数据
"""
raise NotImplementedError

View File

@ -38,8 +38,8 @@ class Bot(abc.ABC):
"""
:参数:
* ``self_id: str``: 机器人 ID
* ``request: HTTPConnection``: request 连接对象
* `self_id: str`: 机器人 ID
* `request: HTTPConnection`: request 连接对象
"""
self.adapter: "Adapter" = adapter
self.self_id: str = self_id
@ -62,8 +62,8 @@ class Bot(abc.ABC):
:参数:
* ``api: str``: API 名称
* ``**data``: API 数据
* `api: str`: API 名称
* `**data`: API 数据
:示例:
@ -131,9 +131,9 @@ class Bot(abc.ABC):
:参数:
* ``event: Event``: 上报事件
* ``message: Union[str, Message, MessageSegment]``: 要发送的消息
* ``**kwargs``
* `event: Event`: 上报事件
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
* `**kwargs`
"""
raise NotImplementedError
@ -144,9 +144,9 @@ class Bot(abc.ABC):
:参数:
* ``bot: Bot``: 当前 bot 对象
* ``api: str``: 调用的 api 名称
* ``data: Dict[str, Any]``: api 调用的参数字典
* `bot: Bot`: 当前 bot 对象
* `api: str`: 调用的 api 名称
* `data: Dict[str, Any]`: api 调用的参数字典
"""
cls._calling_api_hook.add(func)
return func
@ -158,11 +158,11 @@ class Bot(abc.ABC):
:参数:
* ``bot: Bot``: 当前 bot 对象
* ``exception: Optional[Exception]``: 调用 api 时发生的错误
* ``api: str``: 调用的 api 名称
* ``data: Dict[str, Any]``: api 调用的参数字典
* ``result: Any``: api 调用的返回
* `bot: Bot`: 当前 bot 对象
* `exception: Optional[Exception]`: 调用 api 时发生的错误
* `api: str`: 调用的 api 名称
* `data: Dict[str, Any]`: api 调用的参数字典
* `result: Any`: api 调用的返回
"""
cls._called_api_hook.add(func)
return func

View File

@ -20,8 +20,8 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``Literal["message", "notice", "request", "meta_event"]``
* 其他自定义 ``str``
* `Literal["message", "notice", "request", "meta_event"]`
* 其他自定义 `str`
"""
raise NotImplementedError
@ -32,7 +32,7 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``str``
* `str`
"""
raise NotImplementedError
@ -43,7 +43,7 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``str``
* `str`
"""
raise NotImplementedError
@ -52,15 +52,15 @@ class Event(abc.ABC, BaseModel):
def get_log_string(self) -> str:
"""
获取事件日志信息的方法,通常你不需要修改这个方法,只有当希望 NoneBot 隐藏该事件日志时,可以抛出 ``NoLogException`` 异常。
获取事件日志信息的方法,通常你不需要修改这个方法,只有当希望 NoneBot 隐藏该事件日志时,可以抛出 `NoLogException` 异常。
:返回:
* ``str``
* `str`
:异常:
- ``NoLogException``
- `NoLogException`
"""
return f"[{self.get_event_name()}]: {self.get_event_description()}"
@ -71,7 +71,7 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``str``
* `str`
"""
raise NotImplementedError
@ -82,7 +82,7 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``str``
* `str`
"""
raise NotImplementedError
@ -93,17 +93,17 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``Message``
* `Message`
"""
raise NotImplementedError
def get_plaintext(self) -> str:
"""
获取消息纯文本的方法,通常不需要修改,默认通过 ``get_message().extract_plain_text`` 获取。
获取消息纯文本的方法,通常不需要修改,默认通过 `get_message().extract_plain_text` 获取。
:返回:
* ``str``
* `str`
"""
return self.get_message().extract_plain_text()
@ -114,6 +114,6 @@ class Event(abc.ABC, BaseModel):
:返回:
* ``bool``
* `bool`
"""
raise NotImplementedError

View File

@ -99,7 +99,7 @@ class Message(List[TMS], abc.ABC):
"""
:参数:
* ``message: Union[str, list, dict, MessageSegment, Message, Any]``: 消息内容
* `message: Union[str, list, dict, MessageSegment, Message, Any]`: 消息内容
"""
super().__init__(*args, **kwargs)
if message is None:
@ -114,9 +114,9 @@ class Message(List[TMS], abc.ABC):
@classmethod
def template(cls: Type[TM], format_string: Union[str, TM]) -> MessageTemplate[TM]:
"""
根据创建消息模板, 用法和 ``str.format`` 大致相同, 但是可以输出消息对象, 并且支持以 ``Message`` 对象作为消息模板
根据创建消息模板, 用法和 `str.format` 大致相同, 但是可以输出消息对象, 并且支持以 `Message` 对象作为消息模板
并且提供了拓展的格式化控制符, 可以用适用于该消息类型的 ``MessageSegment`` 的工厂方法创建消息
并且提供了拓展的格式化控制符, 可以用适用于该消息类型的 `MessageSegment` 的工厂方法创建消息
:示例:
@ -137,11 +137,11 @@ class Message(List[TMS], abc.ABC):
:参数:
* ``format_string: str``: 格式化字符串
* `format_string: str`: 格式化字符串
:返回:
- ``MessageFormatter[TM]``: 消息格式化器
- `MessageFormatter[TM]`: 消息格式化器
"""
return MessageTemplate(format_string, cls)
@ -190,7 +190,7 @@ class Message(List[TMS], abc.ABC):
:参数:
* ``obj: Union[str, MessageSegment]``: 要添加的消息段
* `obj: Union[str, MessageSegment]`: 要添加的消息段
"""
if isinstance(obj, MessageSegment):
super(Message, self).append(obj)
@ -206,7 +206,7 @@ class Message(List[TMS], abc.ABC):
:参数:
* ``obj: Union[Message, Iterable[MessageSegment]]``: 要添加的消息数组
* `obj: Union[Message, Iterable[MessageSegment]]`: 要添加的消息数组
"""
for segment in obj:
self.append(segment)

View File

@ -51,8 +51,8 @@ class MessageTemplate(Formatter, Generic[TF]):
:参数:
* ``template: Union[str, Message]``: 模板
* ``factory: Union[str, Message]``: 消息构造类型,默认为 `str`
* `template: Union[str, Message]`: 模板
* `factory: Union[str, Message]`: 消息构造类型,默认为 `str`
"""
self.template: TF = template
self.factory: Type[TF] = factory