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/docs/.vuepress/public/plugins.json b/docs/.vuepress/public/plugins.json
index b5c5760b..6fa84155 100644
--- a/docs/.vuepress/public/plugins.json
+++ b/docs/.vuepress/public/plugins.json
@@ -29,7 +29,7 @@
"author": "nonebot",
"desc": "在本地浏览NoneBot文档",
"name": "NoneBot离线文档",
- "repo": "yanyongyu/nonebot2/tree/master/packages/nonebot-plugin-docs"
+ "repo": "nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs"
},
{
"id": "nonebot_plugin_sentry",
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-plugin-docs
+
+_✨ NoneBot 本地文档插件 ✨_
+
+
+
+
+
+
+
+
+
+
+
+
+
+## 使用方式
+
+加载插件并启动 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"