🎨 format docstring

This commit is contained in:
yanyongyu
2020-11-30 11:08:00 +08:00
parent 96cdb9c23e
commit e5463cc564
12 changed files with 257 additions and 3 deletions

View File

@ -10,10 +10,15 @@ from nonebot.typing import Any, Callable, Awaitable, overrides
def escape_tag(s: str) -> str:
"""
:说明:
用于记录带颜色日志时转义 ``<tag>`` 类型特殊标签
:参数:
* ``s: str``: 需要转义的字符串
:返回:
- ``str``
"""
return re.sub(r"</?((?:[fb]g\s)?[^<>\s]*)>", r"\\\g<0>", s)
@ -22,10 +27,15 @@ def escape_tag(s: str) -> str:
def run_sync(func: Callable[..., Any]) -> Callable[..., Awaitable[Any]]:
"""
:说明:
一个用于包装 sync function 为 async function 的装饰器
:参数:
* ``func: Callable[..., Any]``: 被装饰的同步函数
:返回:
- ``Callable[..., Awaitable[Any]]``
"""
@ -42,6 +52,7 @@ def run_sync(func: Callable[..., Any]) -> Callable[..., Awaitable[Any]]:
class DataclassEncoder(json.JSONEncoder):
"""
:说明:
在JSON序列化 ``Message`` (List[Dataclass]) 时使用的 ``JSONEncoder``
"""