From 43eef20b7120c94b5c6d0c690ffe591b6612fbff Mon Sep 17 00:00:00 2001 From: snowy Date: Mon, 19 Aug 2024 10:22:24 +0800 Subject: [PATCH] =?UTF-8?q?:memo:=20=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=B8=ADself=E5=A4=9A=E5=87=BA=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=B3=A8=E8=A7=A3=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=5F=5Finit=5F=5F=E4=B8=A2=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/dev/api/bot/README.md | 32 ++++++++++++++ docs/dev/api/bot/lifespan.md | 12 +++++ docs/dev/api/comm/channel.md | 44 +++++++++++++++++++ docs/dev/api/comm/storage.md | 48 ++++++++++++++++++++ docs/dev/api/config.md | 28 ++++++++++++ docs/dev/api/core/manager.md | 28 ++++++++++++ docs/dev/api/dev/observer.md | 24 ++++++++++ docs/dev/api/dev/plugin.md | 12 +++++ docs/dev/api/log.md | 4 ++ docs/dev/api/plugin/load.md | 56 ++++++++++++++++++++++++ docs/dev/api/plugin/model.md | 24 ++++++++++ docs/dev/api/utils.md | 20 +++++++++ docs/en/dev/api/liteyuki/bot/README.md | 32 ++++++++++++++ docs/en/dev/api/liteyuki/bot/lifespan.md | 12 +++++ docs/en/dev/api/liteyuki/comm/channel.md | 44 +++++++++++++++++++ docs/en/dev/api/liteyuki/comm/storage.md | 48 ++++++++++++++++++++ docs/en/dev/api/liteyuki/config.md | 28 ++++++++++++ docs/en/dev/api/liteyuki/core/manager.md | 28 ++++++++++++ docs/en/dev/api/liteyuki/dev/observer.md | 24 ++++++++++ docs/en/dev/api/liteyuki/dev/plugin.md | 12 +++++ docs/en/dev/api/liteyuki/log.md | 4 ++ docs/en/dev/api/liteyuki/plugin/load.md | 56 ++++++++++++++++++++++++ docs/en/dev/api/liteyuki/plugin/model.md | 24 ++++++++++ docs/en/dev/api/liteyuki/utils.md | 20 +++++++++ 24 files changed, 664 insertions(+) diff --git a/docs/dev/api/bot/README.md b/docs/dev/api/bot/README.md index c7f795f9..8f027bf5 100644 --- a/docs/dev/api/bot/README.md +++ b/docs/dev/api/bot/README.md @@ -193,3 +193,35 @@ Args: Returns: +### ***var*** `executable = sys.executable` + + + +### ***var*** `args = sys.argv` + + + +### ***var*** `chan_active = get_channel(f'{name}-active')` + + + +### ***var*** `cmd = 'start'` + + + +### ***var*** `chan_active = get_channel(f'{process_name}-active')` + + + +### ***var*** `cmd = 'nohup'` + + + +### ***var*** `cmd = 'open'` + + + +### ***var*** `cmd = 'nohup'` + + + diff --git a/docs/dev/api/bot/lifespan.md b/docs/dev/api/bot/lifespan.md index a0200554..396403b4 100644 --- a/docs/dev/api/bot/lifespan.md +++ b/docs/dev/api/bot/lifespan.md @@ -156,3 +156,15 @@ Returns: Returns: +### ***var*** `tasks = []` + + + +### ***var*** `loop = asyncio.get_event_loop()` + + + +### ***var*** `loop = asyncio.new_event_loop()` + + + diff --git a/docs/dev/api/comm/channel.md b/docs/dev/api/comm/channel.md index baf54d89..c05d1cd8 100644 --- a/docs/dev/api/comm/channel.md +++ b/docs/dev/api/comm/channel.md @@ -103,3 +103,47 @@ Returns: 装饰器,装饰一个函数在接收到数据后执行 +### ***var*** `T = TypeVar('T')` + + + +### ***var*** `channel_deliver_active_channel = Channel(_id='channel_deliver_active_channel')` + + + +### ***var*** `channel_deliver_passive_channel = Channel(_id='channel_deliver_passive_channel')` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `recv_chan = Channel[Channel[Any]]('recv_chan')` + + + +### ***var*** `recv_chan = Channel[dict[str, Channel[Any]]]('recv_chan')` + + + +### ***var*** `data = self.conn_recv.recv()` + + + +### ***var*** `func = _callback_funcs[func_id]` + + + +### ***var*** `func = _callback_funcs[func_id]` + + + +### ***var*** `data = self.conn_recv.recv()` + + + +### ***var*** `data = self.conn_recv.recv()` + + + diff --git a/docs/dev/api/comm/storage.md b/docs/dev/api/comm/storage.md index d406e5c1..9042d3a1 100644 --- a/docs/dev/api/comm/storage.md +++ b/docs/dev/api/comm/storage.md @@ -90,3 +90,51 @@ Returns: ###   ***attr*** `_lock: threading.Lock()` +### ***var*** `key = data[1]['key']` + + + +### ***var*** `default = data[1]['default']` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `key = data[1]['key']` + + + +### ***var*** `value = data[1]['value']` + + + +### ***var*** `key = data[1]['key']` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `recv_chan = Channel[Optional[Any]]('recv_chan')` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `recv_chan = Channel[dict[str, Any]]('recv_chan')` + + + diff --git a/docs/dev/api/config.md b/docs/dev/api/config.md index d57e0395..30066528 100644 --- a/docs/dev/api/config.md +++ b/docs/dev/api/config.md @@ -69,3 +69,31 @@ Load config from toml file +### ***var*** `new_config = copy.deepcopy(config)` + + + +### ***var*** `config = yaml.safe_load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = json.load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = toml.load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = {}` + + + +### ***var*** `config = {}` + + + +### ***var*** `config = load_configs_from_dirs('config', no_waring=no_waring)` + + + diff --git a/docs/dev/api/core/manager.md b/docs/dev/api/core/manager.md index 55d09ca4..ed8f2f18 100644 --- a/docs/dev/api/core/manager.md +++ b/docs/dev/api/core/manager.md @@ -81,3 +81,31 @@ Args: Returns: +### ***var*** `TIMEOUT = 10` + + + +### ***var*** `chan_active = get_channel(f'{name}-active')` + + + +### ***var*** `channel_deliver = ChannelDeliver(active=chan_active, passive=chan_passive, channel_deliver_active=channel_deliver_active_channel, channel_deliver_passive=channel_deliver_passive_channel)` + + + +### ***var*** `process = self.processes[name]` + + + +### ***var*** `process = Process(target=self.targets[name][0], args=self.targets[name][1], kwargs=self.targets[name][2], daemon=True)` + + + +### ***var*** `data = chan_active.receive()` + + + +### ***var*** `kwargs = {}` + + + diff --git a/docs/dev/api/dev/observer.md b/docs/dev/api/dev/observer.md index eeabac26..f0f5643b 100644 --- a/docs/dev/api/dev/observer.md +++ b/docs/dev/api/dev/observer.md @@ -65,3 +65,27 @@ Handler for code file changes   +### ***var*** `liteyuki_bot = get_bot()` + + + +### ***var*** `observer = Observer()` + + + +### ***var*** `last_call_time = None` + + + +### ***var*** `code_modified_handler = CodeModifiedHandler()` + + + +### ***var*** `current_time = time.time()` + + + +### ***var*** `last_call_time = current_time` + + + diff --git a/docs/dev/api/dev/plugin.md b/docs/dev/api/dev/plugin.md index b9cc0279..a93c922b 100644 --- a/docs/dev/api/dev/plugin.md +++ b/docs/dev/api/dev/plugin.md @@ -13,3 +13,15 @@ Args: module_path: 插件路径,参考`liteyuki.load_plugin`的函数签名 +### ***var*** `cfg = load_config_in_default()` + + + +### ***var*** `plugins = cfg.get('liteyuki.plugins', [])` + + + +### ***var*** `bot = LiteyukiBot(**cfg)` + + + diff --git a/docs/dev/api/log.md b/docs/dev/api/log.md index 44ba003e..c698f3ba 100644 --- a/docs/dev/api/log.md +++ b/docs/dev/api/log.md @@ -15,3 +15,7 @@ category: API Returns: +### ***var*** `show_icon = config.get('log_icon', True)` + + + diff --git a/docs/dev/api/plugin/load.md b/docs/dev/api/plugin/load.md index 11078545..9669642e 100644 --- a/docs/dev/api/plugin/load.md +++ b/docs/dev/api/plugin/load.md @@ -45,3 +45,59 @@ Returns: str: 设置后的插件名称 name +### ***var*** `module_path = path_to_module_name(Path(module_path)) if isinstance(module_path, Path) else module_path` + + + +### ***var*** `plugins = set()` + + + +### ***var*** `color = 'y'` + + + +### ***var*** `module = import_module(module_path)` + + + +### ***var*** `display_name = module.__name__.split('.')[-1]` + + + +### ***var*** `display_name = format_display_name(f"{metadata.name}({module.__name__.split('.')[-1]})", metadata.type)` + + + +### ***var*** `path = Path(os.path.join(dir_path, f))` + + + +### ***var*** `module_name = None` + + + +### ***var*** `color = 'm'` + + + +### ***var*** `color = 'g'` + + + +### ***var*** `color = 'e'` + + + +### ***var*** `color = 'c'` + + + +### ***var*** `module_name = f'{path_to_module_name(Path(dir_path))}.{f[:-3]}'` + + + +### ***var*** `module_name = path_to_module_name(path)` + + + diff --git a/docs/dev/api/plugin/model.md b/docs/dev/api/plugin/model.md index f7eb3678..fd8fec0c 100644 --- a/docs/dev/api/plugin/model.md +++ b/docs/dev/api/plugin/model.md @@ -63,3 +63,27 @@ extra: dict[str, Any] ###   ***attr*** `model_config: {'arbitrary_types_allowed': True}` +### ***var*** `APPLICATION = 'application'` + + + +### ***var*** `SERVICE = 'service'` + + + +### ***var*** `IMPLEMENTATION = 'implementation'` + + + +### ***var*** `MODULE = 'module'` + + + +### ***var*** `UNCLASSIFIED = 'unclassified'` + + + +### ***var*** `model_config = {'arbitrary_types_allowed': True}` + + + diff --git a/docs/dev/api/utils.md b/docs/dev/api/utils.md index a0b757f8..b215a53d 100644 --- a/docs/dev/api/utils.md +++ b/docs/dev/api/utils.md @@ -57,3 +57,23 @@ Returns: +### ***var*** `IS_MAIN_PROCESS = multiprocessing.current_process().name == 'MainProcess'` + + + +### ***var*** `func_ = getattr(call, '__call__', None)` + + + +### ***var*** `rel_path = path.resolve().relative_to(Path.cwd().resolve())` + + + +### ***var*** `loop = asyncio.get_event_loop()` + + + +### ***var*** `loop = asyncio.new_event_loop()` + + + diff --git a/docs/en/dev/api/liteyuki/bot/README.md b/docs/en/dev/api/liteyuki/bot/README.md index c7f795f9..8f027bf5 100644 --- a/docs/en/dev/api/liteyuki/bot/README.md +++ b/docs/en/dev/api/liteyuki/bot/README.md @@ -193,3 +193,35 @@ Args: Returns: +### ***var*** `executable = sys.executable` + + + +### ***var*** `args = sys.argv` + + + +### ***var*** `chan_active = get_channel(f'{name}-active')` + + + +### ***var*** `cmd = 'start'` + + + +### ***var*** `chan_active = get_channel(f'{process_name}-active')` + + + +### ***var*** `cmd = 'nohup'` + + + +### ***var*** `cmd = 'open'` + + + +### ***var*** `cmd = 'nohup'` + + + diff --git a/docs/en/dev/api/liteyuki/bot/lifespan.md b/docs/en/dev/api/liteyuki/bot/lifespan.md index a0200554..396403b4 100644 --- a/docs/en/dev/api/liteyuki/bot/lifespan.md +++ b/docs/en/dev/api/liteyuki/bot/lifespan.md @@ -156,3 +156,15 @@ Returns: Returns: +### ***var*** `tasks = []` + + + +### ***var*** `loop = asyncio.get_event_loop()` + + + +### ***var*** `loop = asyncio.new_event_loop()` + + + diff --git a/docs/en/dev/api/liteyuki/comm/channel.md b/docs/en/dev/api/liteyuki/comm/channel.md index baf54d89..c05d1cd8 100644 --- a/docs/en/dev/api/liteyuki/comm/channel.md +++ b/docs/en/dev/api/liteyuki/comm/channel.md @@ -103,3 +103,47 @@ Returns: 装饰器,装饰一个函数在接收到数据后执行 +### ***var*** `T = TypeVar('T')` + + + +### ***var*** `channel_deliver_active_channel = Channel(_id='channel_deliver_active_channel')` + + + +### ***var*** `channel_deliver_passive_channel = Channel(_id='channel_deliver_passive_channel')` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `recv_chan = Channel[Channel[Any]]('recv_chan')` + + + +### ***var*** `recv_chan = Channel[dict[str, Channel[Any]]]('recv_chan')` + + + +### ***var*** `data = self.conn_recv.recv()` + + + +### ***var*** `func = _callback_funcs[func_id]` + + + +### ***var*** `func = _callback_funcs[func_id]` + + + +### ***var*** `data = self.conn_recv.recv()` + + + +### ***var*** `data = self.conn_recv.recv()` + + + diff --git a/docs/en/dev/api/liteyuki/comm/storage.md b/docs/en/dev/api/liteyuki/comm/storage.md index d406e5c1..9042d3a1 100644 --- a/docs/en/dev/api/liteyuki/comm/storage.md +++ b/docs/en/dev/api/liteyuki/comm/storage.md @@ -90,3 +90,51 @@ Returns: ###   ***attr*** `_lock: threading.Lock()` +### ***var*** `key = data[1]['key']` + + + +### ***var*** `default = data[1]['default']` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `key = data[1]['key']` + + + +### ***var*** `value = data[1]['value']` + + + +### ***var*** `key = data[1]['key']` + + + +### ***var*** `recv_chan = data[1]['recv_chan']` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `recv_chan = Channel[Optional[Any]]('recv_chan')` + + + +### ***var*** `lock = _get_lock(key)` + + + +### ***var*** `recv_chan = Channel[dict[str, Any]]('recv_chan')` + + + diff --git a/docs/en/dev/api/liteyuki/config.md b/docs/en/dev/api/liteyuki/config.md index d57e0395..30066528 100644 --- a/docs/en/dev/api/liteyuki/config.md +++ b/docs/en/dev/api/liteyuki/config.md @@ -69,3 +69,31 @@ Load config from toml file +### ***var*** `new_config = copy.deepcopy(config)` + + + +### ***var*** `config = yaml.safe_load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = json.load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = toml.load(open(file, 'r', encoding='utf-8'))` + + + +### ***var*** `config = {}` + + + +### ***var*** `config = {}` + + + +### ***var*** `config = load_configs_from_dirs('config', no_waring=no_waring)` + + + diff --git a/docs/en/dev/api/liteyuki/core/manager.md b/docs/en/dev/api/liteyuki/core/manager.md index 55d09ca4..ed8f2f18 100644 --- a/docs/en/dev/api/liteyuki/core/manager.md +++ b/docs/en/dev/api/liteyuki/core/manager.md @@ -81,3 +81,31 @@ Args: Returns: +### ***var*** `TIMEOUT = 10` + + + +### ***var*** `chan_active = get_channel(f'{name}-active')` + + + +### ***var*** `channel_deliver = ChannelDeliver(active=chan_active, passive=chan_passive, channel_deliver_active=channel_deliver_active_channel, channel_deliver_passive=channel_deliver_passive_channel)` + + + +### ***var*** `process = self.processes[name]` + + + +### ***var*** `process = Process(target=self.targets[name][0], args=self.targets[name][1], kwargs=self.targets[name][2], daemon=True)` + + + +### ***var*** `data = chan_active.receive()` + + + +### ***var*** `kwargs = {}` + + + diff --git a/docs/en/dev/api/liteyuki/dev/observer.md b/docs/en/dev/api/liteyuki/dev/observer.md index eeabac26..f0f5643b 100644 --- a/docs/en/dev/api/liteyuki/dev/observer.md +++ b/docs/en/dev/api/liteyuki/dev/observer.md @@ -65,3 +65,27 @@ Handler for code file changes   +### ***var*** `liteyuki_bot = get_bot()` + + + +### ***var*** `observer = Observer()` + + + +### ***var*** `last_call_time = None` + + + +### ***var*** `code_modified_handler = CodeModifiedHandler()` + + + +### ***var*** `current_time = time.time()` + + + +### ***var*** `last_call_time = current_time` + + + diff --git a/docs/en/dev/api/liteyuki/dev/plugin.md b/docs/en/dev/api/liteyuki/dev/plugin.md index b9cc0279..a93c922b 100644 --- a/docs/en/dev/api/liteyuki/dev/plugin.md +++ b/docs/en/dev/api/liteyuki/dev/plugin.md @@ -13,3 +13,15 @@ Args: module_path: 插件路径,参考`liteyuki.load_plugin`的函数签名 +### ***var*** `cfg = load_config_in_default()` + + + +### ***var*** `plugins = cfg.get('liteyuki.plugins', [])` + + + +### ***var*** `bot = LiteyukiBot(**cfg)` + + + diff --git a/docs/en/dev/api/liteyuki/log.md b/docs/en/dev/api/liteyuki/log.md index 44ba003e..c698f3ba 100644 --- a/docs/en/dev/api/liteyuki/log.md +++ b/docs/en/dev/api/liteyuki/log.md @@ -15,3 +15,7 @@ category: API Returns: +### ***var*** `show_icon = config.get('log_icon', True)` + + + diff --git a/docs/en/dev/api/liteyuki/plugin/load.md b/docs/en/dev/api/liteyuki/plugin/load.md index 11078545..9669642e 100644 --- a/docs/en/dev/api/liteyuki/plugin/load.md +++ b/docs/en/dev/api/liteyuki/plugin/load.md @@ -45,3 +45,59 @@ Returns: str: 设置后的插件名称 name +### ***var*** `module_path = path_to_module_name(Path(module_path)) if isinstance(module_path, Path) else module_path` + + + +### ***var*** `plugins = set()` + + + +### ***var*** `color = 'y'` + + + +### ***var*** `module = import_module(module_path)` + + + +### ***var*** `display_name = module.__name__.split('.')[-1]` + + + +### ***var*** `display_name = format_display_name(f"{metadata.name}({module.__name__.split('.')[-1]})", metadata.type)` + + + +### ***var*** `path = Path(os.path.join(dir_path, f))` + + + +### ***var*** `module_name = None` + + + +### ***var*** `color = 'm'` + + + +### ***var*** `color = 'g'` + + + +### ***var*** `color = 'e'` + + + +### ***var*** `color = 'c'` + + + +### ***var*** `module_name = f'{path_to_module_name(Path(dir_path))}.{f[:-3]}'` + + + +### ***var*** `module_name = path_to_module_name(path)` + + + diff --git a/docs/en/dev/api/liteyuki/plugin/model.md b/docs/en/dev/api/liteyuki/plugin/model.md index f7eb3678..fd8fec0c 100644 --- a/docs/en/dev/api/liteyuki/plugin/model.md +++ b/docs/en/dev/api/liteyuki/plugin/model.md @@ -63,3 +63,27 @@ extra: dict[str, Any] ###   ***attr*** `model_config: {'arbitrary_types_allowed': True}` +### ***var*** `APPLICATION = 'application'` + + + +### ***var*** `SERVICE = 'service'` + + + +### ***var*** `IMPLEMENTATION = 'implementation'` + + + +### ***var*** `MODULE = 'module'` + + + +### ***var*** `UNCLASSIFIED = 'unclassified'` + + + +### ***var*** `model_config = {'arbitrary_types_allowed': True}` + + + diff --git a/docs/en/dev/api/liteyuki/utils.md b/docs/en/dev/api/liteyuki/utils.md index a0b757f8..b215a53d 100644 --- a/docs/en/dev/api/liteyuki/utils.md +++ b/docs/en/dev/api/liteyuki/utils.md @@ -57,3 +57,23 @@ Returns: +### ***var*** `IS_MAIN_PROCESS = multiprocessing.current_process().name == 'MainProcess'` + + + +### ***var*** `func_ = getattr(call, '__call__', None)` + + + +### ***var*** `rel_path = path.resolve().relative_to(Path.cwd().resolve())` + + + +### ***var*** `loop = asyncio.get_event_loop()` + + + +### ***var*** `loop = asyncio.new_event_loop()` + + +