From 2f5e523b5a8d5f61ff9528dcb5171ef0fea32cd7 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Sat, 25 Dec 2021 00:11:48 +0800 Subject: [PATCH] :memo: write install guide and init tutorial --- website/docs/guide/start/editor-support.md | 33 +++++++++++++++ website/docs/guide/start/install-adapter.md | 40 ++++++++++++++++++ website/docs/guide/start/install-driver.md | 42 +++++++++++++++++++ website/docs/guide/start/install-plugin.md | 40 ++++++++++++++++++ website/docs/guide/start/installation.md | 4 ++ website/docs/guide/start/nb-cli.md | 4 +- .../guide/start/{problem.md => question.md} | 2 + website/docs/guide/tutorial/_category_.json | 4 ++ .../{ => tutorial}/creating-a-project.md | 14 +++---- 9 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 website/docs/guide/start/editor-support.md create mode 100644 website/docs/guide/start/install-adapter.md create mode 100644 website/docs/guide/start/install-driver.md create mode 100644 website/docs/guide/start/install-plugin.md rename website/docs/guide/start/{problem.md => question.md} (94%) create mode 100644 website/docs/guide/tutorial/_category_.json rename website/docs/guide/{ => tutorial}/creating-a-project.md (83%) diff --git a/website/docs/guide/start/editor-support.md b/website/docs/guide/start/editor-support.md new file mode 100644 index 00000000..6afe0b3c --- /dev/null +++ b/website/docs/guide/start/editor-support.md @@ -0,0 +1,33 @@ +--- +sidebar_position: 80 +description: 编辑器支持 +--- + +# 编辑器支持 + +框架基于 [PEP484](https://www.python.org/dev/peps/pep-0484/), [PEP 561](https://www.python.org/dev/peps/pep-0517/), [PEP8](https://www.python.org/dev/peps/pep-0008/) 等规范进行开发并且是 **Fully Typed**。框架使用 `pyright` (`pylance`) 工具进行类型检查,确保代码可以被编辑器正确解析。 + +## 编辑器推荐配置 + +### Visual Studio Code + +在 Visual Studio Code 中,可以使用 `pylance` Language Server 并启用 `Type Checking` 以达到最佳开发体验。 + +向 `.vscode` 文件夹中对应文件添加以下配置并在 VSCode 插件面板安装推荐插件: + +```json title=extensions.json +{ + "recommendations": ["ms-python.python", "ms-python.vscode-pylance"] +} +``` + +```json title=settings.json +{ + "python.languageServer": "Pylance", + "python.analysis.typeCheckingMode": "basic" +} +``` + +### 其他 + +欢迎提交 Pull Request 添加其他编辑器配置推荐。点击左下角 `Edit this page` 前往编辑。 diff --git a/website/docs/guide/start/install-adapter.md b/website/docs/guide/start/install-adapter.md new file mode 100644 index 00000000..4906a0e1 --- /dev/null +++ b/website/docs/guide/start/install-adapter.md @@ -0,0 +1,40 @@ +--- +sidebar_position: 2 +description: 通过脚手架, pip 安装适配器 +--- + +# 安装协议适配器 + +## 查看 + +前往 [商店](/store) 即可查看所有协议适配器。 + +或者使用 `nb-cli` 命令行查看: + +```bash +nb adapter list +``` + +## 安装 + +前往 [商店](/store) 点击复制 `nb-cli` 安装命令至命令行执行即可安装。 + +或者自行输入命令安装: + +```bash +nb adapter install +``` + +或者使用交互模式安装: + +```bash +nb adapter install +``` + +也可以使用 `pip` 安装 + +```bash +pip install +``` + + diff --git a/website/docs/guide/start/install-driver.md b/website/docs/guide/start/install-driver.md new file mode 100644 index 00000000..4707cb00 --- /dev/null +++ b/website/docs/guide/start/install-driver.md @@ -0,0 +1,42 @@ +--- +sidebar_position: 1 +description: 通过脚手架, pip 安装驱动器 +--- + +# 安装驱动器 + +NoneBot 在默认安装情况下内置了 `fastapi` 服务端驱动器,其他驱动器如 `httpx`, `aiohttp` 则需要额外安装。 + +## 查看 + +前往 [商店](/store) 即可查看所有驱动器。 + +或者使用 `nb-cli` 命令行查看: + +```bash +nb driver list +``` + +## 安装 + +前往 [商店](/store) 点击复制 `nb-cli` 安装命令至命令行执行即可安装。 + +或者自行输入命令安装: + +```bash +nb driver install +``` + +或者使用交互模式安装: + +```bash +nb driver install +``` + +也可以使用 `pip` 安装 + +```bash +pip install +``` + + diff --git a/website/docs/guide/start/install-plugin.md b/website/docs/guide/start/install-plugin.md new file mode 100644 index 00000000..7d459141 --- /dev/null +++ b/website/docs/guide/start/install-plugin.md @@ -0,0 +1,40 @@ +--- +sidebar_position: 3 +description: 通过脚手架, pip 安装插件 +--- + +# 安装第三方插件 + +## 查看 + +前往 [商店](/store) 即可查看所有发布的插件。 + +或者使用 `nb-cli` 命令行查看: + +```bash +nb plugin list +``` + +## 安装 + +前往 [商店](/store) 点击复制 `nb-cli` 安装命令至命令行执行即可安装。 + +或者自行输入命令安装: + +```bash +nb plugin install +``` + +或者使用交互模式安装: + +```bash +nb plugin install +``` + +也可以使用 `pip` 安装 + +```bash +pip install +``` + + diff --git a/website/docs/guide/start/installation.md b/website/docs/guide/start/installation.md index c5196ae3..5ff6463d 100644 --- a/website/docs/guide/start/installation.md +++ b/website/docs/guide/start/installation.md @@ -34,6 +34,10 @@ pip uninstall nonebot +:::important 提示 +`nb-cli` 的使用方法详见 [使用脚手架](./nb-cli.md) +::: + ## 不使用脚手架 (纯净安装) 如果你不想使用脚手架,可以直接安装 `nonebot2`,并自行完成开发配置。 diff --git a/website/docs/guide/start/nb-cli.md b/website/docs/guide/start/nb-cli.md index 7e794c78..5ff94380 100644 --- a/website/docs/guide/start/nb-cli.md +++ b/website/docs/guide/start/nb-cli.md @@ -1,5 +1,5 @@ --- -sidebar_position: 1 +sidebar_position: 90 description: 使用 nb-cli 帮助开发 options: @@ -9,3 +9,5 @@ options: --- # 使用脚手架 + + diff --git a/website/docs/guide/start/problem.md b/website/docs/guide/start/question.md similarity index 94% rename from website/docs/guide/start/problem.md rename to website/docs/guide/start/question.md index b120ef69..e7f0fcf1 100644 --- a/website/docs/guide/start/problem.md +++ b/website/docs/guide/start/question.md @@ -1,4 +1,6 @@ --- +sidebar-position: 100 +description: 如何获取帮助 --- # 遇到问题 diff --git a/website/docs/guide/tutorial/_category_.json b/website/docs/guide/tutorial/_category_.json new file mode 100644 index 00000000..df4a90ff --- /dev/null +++ b/website/docs/guide/tutorial/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 2, + "label": "教程" +} diff --git a/website/docs/guide/creating-a-project.md b/website/docs/guide/tutorial/creating-a-project.md similarity index 83% rename from website/docs/guide/creating-a-project.md rename to website/docs/guide/tutorial/creating-a-project.md index ce2a76b0..3013c2c7 100644 --- a/website/docs/guide/creating-a-project.md +++ b/website/docs/guide/tutorial/creating-a-project.md @@ -1,17 +1,13 @@ --- -sidebar_position: 4 +sidebar_position: 0 options: menu: - weight: 40 + weight: 20 category: guide --- -# 创建一个完整的项目 - -上一章中我们已经运行了一个简单的 NoneBot 实例,在这一章,我们将从零开始一个完整的项目。 - -## 目录结构 +# 创建项目 可以使用 `nb-cli` 或者自行创建完整的项目目录: @@ -19,6 +15,8 @@ options: nb create ``` +## 目录结构 + :::vue AweSome-Bot @@ -46,7 +44,7 @@ AweSome-Bot :::warning 提示 如果您使用如 `VSCode` / `PyCharm` 等 IDE 启动 nonebot,请检查 IDE 当前工作空间目录是否与当前侧边栏打开目录一致。 -- 注意:在二者不一致的环境下可能导致 nonebot 读取配置文件和插件等不符合预期 +> 注意:在二者不一致的环境下可能导致 nonebot 读取配置文件和插件等不符合预期 :::