diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index fcca4ea8..c77a0550 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -26,6 +26,10 @@ version-resolver: - 'patch' default: patch template: | - ## Changes + ## Documentation + + See: https://v2.nonebot.dev + + ## 💫 Changes $CHANGES diff --git a/.github/workflows/nonebot_plugin_docs.yml b/.github/workflows/nonebot_plugin_docs.yml new file mode 100644 index 00000000..757ef41a --- /dev/null +++ b/.github/workflows/nonebot_plugin_docs.yml @@ -0,0 +1,40 @@ +name: Release Nonebot Plugin Docs + +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: '12' + - run: npm ci + - name: Build Docs + env: + VUEPRESS_BASE: '/docs/' + run: npx vuepress build docs --dest packages/nonebot-plugin-docs/nonebot_plugin_docs/dist + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + architecture: "x64" + - name: Install Poetry + run: | + python -m pip install --upgrade pip + pip install poetry + + - name: Publish Package + run: | + export NONEBOT_VERSION=`poetry version -s` + cd packages/nonebot-plugin-docs/ + poetry version $NONEBOT_VERSION + poetry build + poetry publish -u ${{secrets.PYPI_USERNAME}} -p ${{secrets.PYPI_PASSWORD}} diff --git a/.github/workflows/plugin_issue.yml b/.github/workflows/plugin_issue.yml new file mode 100644 index 00000000..573a324b --- /dev/null +++ b/.github/workflows/plugin_issue.yml @@ -0,0 +1,25 @@ +name: 'Plugin Issue Bot' + +on: + push: + branches: + - master + issues: + types: [opened, reopened, edited] + pull_request: + types: [closed] + +jobs: + issue_bot: + runs-on: ubuntu-latest + name: plugin issue bot + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: NoneBot2 Plugin Issue Bot + uses: he0119/nonebot2-plugin-issue-bot@v0.2 + with: + token: ${{ secrets.GH_TOKEN }} + base: master + path: docs/.vuepress/public/plugins.json diff --git a/docs/.vuepress/public/plugins.json b/docs/.vuepress/public/plugins.json index 007aec4c..6fa84155 100644 --- a/docs/.vuepress/public/plugins.json +++ b/docs/.vuepress/public/plugins.json @@ -14,5 +14,29 @@ "desc": "将B站UP主的动态和直播信息推送至QQ", "author": "SK-415", "repo": "SK-415/HarukaBot" + }, + { + "id": "nonebot_plugin_rauthman", + "link": "nonebot-plugin-rauthman", + "name": "rauthman", + "desc": "基于规则的授权管理", + "author": "Lancercmd", + "repo": "Lancercmd/nonebot_plugin_rauthman" + }, + { + "id": "nonebot_plugin_docs", + "link": "nonebot-plugin-docs", + "author": "nonebot", + "desc": "在本地浏览NoneBot文档", + "name": "NoneBot离线文档", + "repo": "nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs" + }, + { + "id": "nonebot_plugin_sentry", + "link": "nonebot-plugin-sentry", + "author": "yanyongyu", + "desc": "使用Sentry监控机器人日志并处理报错", + "name": "Sentry日志监控", + "repo": "cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_sentry" } -] +] \ No newline at end of file diff --git a/packages/nonebot-plugin-docs/README.md b/packages/nonebot-plugin-docs/README.md new file mode 100644 index 00000000..df099b03 --- /dev/null +++ b/packages/nonebot-plugin-docs/README.md @@ -0,0 +1,27 @@ +

+ nonebot +

+ +
+ +# nonebot-plugin-docs + +_✨ NoneBot 本地文档插件 ✨_ + +
+ +

+ + license + + + pypi + + python +

+ +## 使用方式 + +加载插件并启动 Bot ,在浏览器内打开 `http://host:port/docs/`。 + +具体网址会在控制台内输出。 diff --git a/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py b/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py new file mode 100644 index 00000000..161cd626 --- /dev/null +++ b/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py @@ -0,0 +1,25 @@ +import importlib + +import nonebot +from nonebot.log import logger + + +def init(): + driver = nonebot.get_driver() + try: + _module = importlib.import_module( + f"nonebot_plugin_docs.drivers.{driver.type}") + except ImportError: + logger.warning(f"Driver {driver.type} not supported") + return + register_route = getattr(_module, "register_route") + register_route(driver) + host = str(driver.config.host) + port = driver.config.port + if host in ["0.0.0.0", "127.0.0.1"]: + host = "localhost" + logger.opt(colors=True).info(f"Nonebot docs will be running at: " + f"http://{host}:{port}/docs/") + + +init() diff --git a/packages/nonebot-plugin-docs/nonebot_plugin_docs/drivers/fastapi.py b/packages/nonebot-plugin-docs/nonebot_plugin_docs/drivers/fastapi.py new file mode 100644 index 00000000..da598d19 --- /dev/null +++ b/packages/nonebot-plugin-docs/nonebot_plugin_docs/drivers/fastapi.py @@ -0,0 +1,14 @@ +from pathlib import Path + +from nonebot.drivers.fastapi import Driver +from fastapi.staticfiles import StaticFiles + + +def register_route(driver: Driver): + app = driver.server_app + + static_path = str((Path(__file__).parent / ".." / "dist").resolve()) + + app.mount("/docs", + StaticFiles(directory=static_path, html=True), + name="docs") diff --git a/packages/nonebot-plugin-docs/pyproject.toml b/packages/nonebot-plugin-docs/pyproject.toml new file mode 100644 index 00000000..7f3a49bc --- /dev/null +++ b/packages/nonebot-plugin-docs/pyproject.toml @@ -0,0 +1,22 @@ +[tool.poetry] +name = "nonebot-plugin-docs" +version = "2.0.0a6.post1" +description = "View NoneBot2 Docs Locally" +authors = ["yanyongyu "] +license = "MIT" +readme = "README.md" +homepage = "https://github.com/nonebot/nonebot2/blob/master/packages/nonebot-plugin-docs" +repository = "https://github.com/nonebot/nonebot2" +keywords = ["nonebot", "nonebot2", "docs"] +include = ["nonebot_plugin_docs/dist/**/*"] + + +[tool.poetry.dependencies] +python = "^3.7" +nonebot2 = "^2.0.0-alpha.1" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api"