mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-11-04 08:56:42 +00:00 
			
		
		
		
	💡 update docstring
This commit is contained in:
		@@ -49,9 +49,18 @@ sidebarDepth: 0
 | 
				
			|||||||
* `load_builtin_plugins` => `nonebot.plugin.load_builtin_plugins`
 | 
					* `load_builtin_plugins` => `nonebot.plugin.load_builtin_plugins`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `get_plugin` => `nonebot.plugin.get_plugin`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `get_loaded_plugins` => `nonebot.plugin.get_loaded_plugins`
 | 
					* `get_loaded_plugins` => `nonebot.plugin.get_loaded_plugins`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `export` => `nonebot.plugin.export`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `require` => `nonebot.plugin.require`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## `get_driver()`
 | 
					## `get_driver()`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,37 @@ sidebarDepth: 0
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## _class_ `Export`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					基类:`dict`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **说明**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    插件导出内容以使得其他插件可以获得。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **示例**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```python
 | 
				
			||||||
 | 
					nonebot.export().default = "bar"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@nonebot.export()
 | 
				
			||||||
 | 
					def some_function():
 | 
				
			||||||
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# this don't work under python 3.9
 | 
				
			||||||
 | 
					# use
 | 
				
			||||||
 | 
					# export = nonebot.export(); @export.sub
 | 
				
			||||||
 | 
					# instead
 | 
				
			||||||
 | 
					@nonebot.export().sub
 | 
				
			||||||
 | 
					def something_else():
 | 
				
			||||||
 | 
					    pass
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## _class_ `Plugin`
 | 
					## _class_ `Plugin`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
基类:`object`
 | 
					基类:`object`
 | 
				
			||||||
@@ -59,6 +90,15 @@ sidebarDepth: 0
 | 
				
			|||||||
* **说明**: 插件内定义的 `Matcher`
 | 
					* **说明**: 插件内定义的 `Matcher`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `export`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **类型**: `Export`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **说明**: 插件内定义的导出内容
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## `on(type='', rule=None, permission=None, *, handlers=None, temp=False, priority=1, block=False, state=None)`
 | 
					## `on(type='', rule=None, permission=None, *, handlers=None, temp=False, priority=1, block=False, state=None)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -614,12 +654,35 @@ sidebarDepth: 0
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## `get_plugin(name)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **说明**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    获取当前导入的某个插件。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **参数**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    * `name: str`: 插件名,与 `load_plugin` 参数一致。如果为 `load_plugins` 导入的插件,则为文件(夹)名。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **返回**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    * `Optional[Plugin]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## `get_loaded_plugins()`
 | 
					## `get_loaded_plugins()`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* **说明**
 | 
					* **说明**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    获取当前已导入的插件。
 | 
					    获取当前已导入的所有插件。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -627,3 +690,42 @@ sidebarDepth: 0
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    * `Set[Plugin]`
 | 
					    * `Set[Plugin]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## `export()`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **说明**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    获取插件的导出内容对象
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **返回**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    * `Export`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## `require(name)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **说明**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    获取一个插件的导出内容
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **参数**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    * `name: str`: 插件名,与 `load_plugin` 参数一致。如果为 `load_plugins` 导入的插件,则为文件(夹)名。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* **返回**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    * `Optional[Export]`
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,10 @@
 | 
				
			|||||||
- ``load_plugin`` => ``nonebot.plugin.load_plugin``
 | 
					- ``load_plugin`` => ``nonebot.plugin.load_plugin``
 | 
				
			||||||
- ``load_plugins`` => ``nonebot.plugin.load_plugins``
 | 
					- ``load_plugins`` => ``nonebot.plugin.load_plugins``
 | 
				
			||||||
- ``load_builtin_plugins`` => ``nonebot.plugin.load_builtin_plugins``
 | 
					- ``load_builtin_plugins`` => ``nonebot.plugin.load_builtin_plugins``
 | 
				
			||||||
 | 
					- ``get_plugin`` => ``nonebot.plugin.get_plugin``
 | 
				
			||||||
- ``get_loaded_plugins`` => ``nonebot.plugin.get_loaded_plugins``
 | 
					- ``get_loaded_plugins`` => ``nonebot.plugin.get_loaded_plugins``
 | 
				
			||||||
 | 
					- ``export`` => ``nonebot.plugin.export``
 | 
				
			||||||
 | 
					- ``require`` => ``nonebot.plugin.require``
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import importlib
 | 
					import importlib
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,10 @@ class Export(dict):
 | 
				
			|||||||
        def some_function():
 | 
					        def some_function():
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # this don't work under python 3.9
 | 
				
			||||||
 | 
					        # use
 | 
				
			||||||
 | 
					        # export = nonebot.export(); @export.sub
 | 
				
			||||||
 | 
					        # instead
 | 
				
			||||||
        @nonebot.export().sub
 | 
					        @nonebot.export().sub
 | 
				
			||||||
        def something_else():
 | 
					        def something_else():
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
@@ -86,6 +90,10 @@ class Plugin(object):
 | 
				
			|||||||
    - **说明**: 插件内定义的 ``Matcher``
 | 
					    - **说明**: 插件内定义的 ``Matcher``
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    export: Export
 | 
					    export: Export
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    - **类型**: ``Export``
 | 
				
			||||||
 | 
					    - **说明**: 插件内定义的导出内容
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def on(type: str = "",
 | 
					def on(type: str = "",
 | 
				
			||||||
@@ -539,9 +547,23 @@ def get_loaded_plugins() -> Set[Plugin]:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def export() -> Export:
 | 
					def export() -> Export:
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    :说明:
 | 
				
			||||||
 | 
					      获取插件的导出内容对象
 | 
				
			||||||
 | 
					    :返回:
 | 
				
			||||||
 | 
					      - ``Export``
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
    return _export.get()
 | 
					    return _export.get()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def require(name: str) -> Optional[Export]:
 | 
					def require(name: str) -> Optional[Export]:
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    :说明:
 | 
				
			||||||
 | 
					      获取一个插件的导出内容
 | 
				
			||||||
 | 
					    :参数:
 | 
				
			||||||
 | 
					      * ``name: str``: 插件名,与 ``load_plugin`` 参数一致。如果为 ``load_plugins`` 导入的插件,则为文件(夹)名。
 | 
				
			||||||
 | 
					    :返回:
 | 
				
			||||||
 | 
					      - ``Optional[Export]``
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
    plugin = get_plugin(name)
 | 
					    plugin = get_plugin(name)
 | 
				
			||||||
    return plugin.export if plugin else None
 | 
					    return plugin.export if plugin else None
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user