🔀 Merge pull request #87

Plugin: 合并docs插件至官方仓库
This commit is contained in:
Ju4tCode 2020-11-28 12:06:32 +08:00 committed by GitHub
commit 96cdb9c23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 183 additions and 2 deletions

View File

@ -26,6 +26,10 @@ version-resolver:
- 'patch'
default: patch
template: |
## Changes
## Documentation
See: https://v2.nonebot.dev
## 💫 Changes
$CHANGES

View File

@ -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}}

25
.github/workflows/plugin_issue.yml vendored Normal file
View File

@ -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

View File

@ -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"
}
]
]

View File

@ -0,0 +1,27 @@
<p align="center">
<a href="https://v2.nonebot.dev/"><img src="https://raw.githubusercontent.com/nonebot/nonebot2/master/docs/.vuepress/public/logo.png" width="200" height="200" alt="nonebot"></a>
</p>
<div align="center">
# nonebot-plugin-docs
_✨ NoneBot 本地文档插件 ✨_
</div>
<p align="center">
<a href="https://raw.githubusercontent.com/nonebot/nonebot2/master/LICENSE">
<img src="https://img.shields.io/github/license/nonebot/nonebot2.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-docs">
<img src="https://img.shields.io/pypi/v/nonebot-plugin-docs.svg" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.7+-blue.svg" alt="python">
</p>
## 使用方式
加载插件并启动 Bot ,在浏览器内打开 `http://host:port/docs/`
具体网址会在控制台内输出。

View File

@ -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"<b><u>http://{host}:{port}/docs/</u></b>")
init()

View File

@ -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")

View File

@ -0,0 +1,22 @@
[tool.poetry]
name = "nonebot-plugin-docs"
version = "2.0.0a6.post1"
description = "View NoneBot2 Docs Locally"
authors = ["yanyongyu <yanyongyu_1@126.com>"]
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"