mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-06-06 12:26:38 +00:00
🔀 Merge pull request #81
This commit is contained in:
commit
2bf63ce8aa
@ -1,7 +1,7 @@
|
|||||||
name: Build API Doc
|
name: Build API Doc
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request:
|
||||||
types: [ opened, synchronize, reopened ]
|
types: [ opened, synchronize, reopened ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -12,7 +12,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
@ -32,11 +31,7 @@ jobs:
|
|||||||
- name: Copy Files
|
- name: Copy Files
|
||||||
run: cp -r ./build/markdown/* ./docs/api/
|
run: cp -r ./build/markdown/* ./docs/api/
|
||||||
|
|
||||||
- run: |
|
- uses: actions/upload-artifact@v2
|
||||||
git config user.name nonebot
|
with:
|
||||||
git config user.email nonebot@nonebot.dev
|
name: docs
|
||||||
git add .
|
path: docs/
|
||||||
git diff-index --quiet HEAD || git commit -m ":memo: update api docs"
|
|
||||||
git remote -vv
|
|
||||||
git remote add target ${{github.event.pull_request.head.repo.clone_url}}
|
|
||||||
git push target HEAD:${{github.event.pull_request.head.ref}}
|
|
33
.github/workflows/upload_docs.yml
vendored
Normal file
33
.github/workflows/upload_docs.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Upload API Doc
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Build API Doc"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
upload:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.workflow_run.head_sha }}
|
||||||
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
|
- uses: dawidd6/action-download-artifact@v2
|
||||||
|
with:
|
||||||
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||||
|
name: docs
|
||||||
|
path: docs/
|
||||||
|
|
||||||
|
- env:
|
||||||
|
REF: ${{ github.event.workflow_run.head_branch }}
|
||||||
|
run: |
|
||||||
|
git config user.name GitHub
|
||||||
|
git config user.email noreply@github.com
|
||||||
|
git add .
|
||||||
|
git diff-index --quiet HEAD || git commit -m ":memo: update api docs"
|
||||||
|
git remote add target "https://github.com/${{ github.event.workflow_run.head_repository.full_name }}.git"
|
||||||
|
git push target HEAD:$REF
|
@ -118,7 +118,21 @@ module.exports = context => ({
|
|||||||
title: "进阶",
|
title: "进阶",
|
||||||
collapsable: false,
|
collapsable: false,
|
||||||
sidebar: "auto",
|
sidebar: "auto",
|
||||||
children: ["", "scheduler", "permission", "runtime-hook"]
|
children: [
|
||||||
|
"",
|
||||||
|
"scheduler",
|
||||||
|
"permission",
|
||||||
|
"runtime-hook",
|
||||||
|
"export-and-require"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "发布",
|
||||||
|
collapsable: false,
|
||||||
|
sidebar: "auto",
|
||||||
|
children: [
|
||||||
|
"publish-plugin"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"/api/": [
|
"/api/": [
|
||||||
|
1
docs/advanced/export-and-require.md
Normal file
1
docs/advanced/export-and-require.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# 跨插件访问
|
@ -1 +1 @@
|
|||||||
# 权限控制
|
# 权限控制
|
||||||
|
1
docs/advanced/publish-plugin.md
Normal file
1
docs/advanced/publish-plugin.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# 发布插件
|
@ -1 +1 @@
|
|||||||
# 运行时插槽
|
# 运行时插槽
|
||||||
|
@ -1 +1 @@
|
|||||||
# 定时任务
|
# 定时任务
|
||||||
|
@ -44,7 +44,8 @@ pip install nonebot2[scheduler]
|
|||||||
poetry add nonebot2[scheduler]
|
poetry add nonebot2[scheduler]
|
||||||
```
|
```
|
||||||
|
|
||||||
[View On GitHub](https://github.com/agronholm/apscheduler)
|
[](https://github.com/agronholm/apscheduler)
|
||||||
|
|
||||||
|
|
||||||
### NoneBot-Test
|
### NoneBot-Test
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ pip install nonebot2[test]
|
|||||||
poetry add nonebot2[test]
|
poetry add nonebot2[test]
|
||||||
```
|
```
|
||||||
|
|
||||||
[View On GitHub](https://github.com/nonebot/nonebot-test)
|
[](https://github.com/nonebot/nonebot-test)
|
||||||
|
|
||||||
### CLI
|
### CLI
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ pip install nonebot2[cli]
|
|||||||
poetry add nonebot2[cli]
|
poetry add nonebot2[cli]
|
||||||
```
|
```
|
||||||
|
|
||||||
[View On GitHub](https://github.com/yanyongyu/nb-cli)
|
[](https://github.com/yanyongyu/nb-cli)
|
||||||
|
|
||||||
### 我全都要
|
### 我全都要
|
||||||
|
|
||||||
|
@ -52,12 +52,7 @@ if __name__ == "__main__":
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
:::danger 警告
|
:::danger 警告
|
||||||
插件间不应该存在过多的耦合,如果确实需要导入某个插件内的数据,可以使用如下两种方法:
|
插件间不应该存在过多的耦合,如果确实需要导入某个插件内的数据,可以参考 [进阶-跨插件访问](../advanced/export-and-require.md)
|
||||||
|
|
||||||
1. (推荐) `from plugin_name import xxx` 而非 `from awesome_bot.plugins.plugin_name import xxx`
|
|
||||||
2. 在需要导入其他插件的文件中添加 `__package__ = "plugins"; from .plugin_name import xxx` (将共同的上层目录设定为父包后使用相对导入)
|
|
||||||
|
|
||||||
具体可以参考:[nonebot/nonebot2#32](https://github.com/nonebot/nonebot2/issues/32)
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## 加载单个插件
|
## 加载单个插件
|
||||||
@ -113,10 +108,6 @@ _sub_plugins |= nonebot.load_plugins(
|
|||||||
|
|
||||||
插件将会被加载并存储于 `_sub_plugins` 中。
|
插件将会被加载并存储于 `_sub_plugins` 中。
|
||||||
|
|
||||||
:::tip 提示
|
|
||||||
如果在父插件中需要定义事件响应器,应在**子插件被加载后**进行定义
|
|
||||||
:::
|
|
||||||
|
|
||||||
## 运行结果
|
## 运行结果
|
||||||
|
|
||||||
尝试运行 `nb run` 或者 `python bot.py`,可以看到日志输出了类似如下内容:
|
尝试运行 `nb run` 或者 `python bot.py`,可以看到日志输出了类似如下内容:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user