Skip to content

Commit

Permalink
🎨 refactor: 文档结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Lain. committed Apr 28, 2024
1 parent bac575a commit b3552fb
Show file tree
Hide file tree
Showing 27 changed files with 1,221 additions and 252 deletions.
96 changes: 88 additions & 8 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,67 @@ export default defineConfig({
themeConfig: {
siteTitle: '主页',
nav: [
{ text: '快速开始', link: '/start' },
{ text: '开发文档', link: '/develop/index' },
{ text: 'elements', link: '/develop/elements' },
{
text: '快速开始',
items: [
{ text: '目录', link: '/start/index' },
{ text: '框架', link: '/start/start' },
{ text: '渲染器', link: '/start/Renderer' },
{ text: '适配器', link: '/start/adapter' }
]
},
{
text: '事件',
items: [
{ text: '目录', link: '/event/index' },
{ text: '消息事件', link: '/event/message' },
{ text: '通知事件', link: '/event/notice' },
{ text: '请求事件', link: '/event/request' }
]
},
{
text: '开发指南',
items: [
{ text: '目录', link: '/develop/index' },
{ text: '插件规范', link: '/develop/standard' },
{ text: '开发插件', link: '/develop/plugin' },
{ text: '开发插件包', link: '/develop/plugins' }
]
},
{
text: '开发工具',
items: [
{ text: '目录', link: '/utils/index' },
{ text: 'karin', link: '/utils/karin' },
{ text: 'segment', link: '/utils/segment' },
{ text: 'redis', link: '/utils/redis' },
{ text: 'update', link: '/utils/update' },
{ text: 'YamlEditor', link: '/utils/YamlEditor' },
{ text: 'Renderer', link: '/utils/Renderer' }
]
},
{
text: 'Api',
items: [
{ text: '目录', link: '/api/index' },
{ text: 'kritor', link: '/api/kritor' },
{ text: 'OneBot11', link: '/api/OneBot11' }
]
},
{ text: '插件索引', link: '/plugins/index' },
],
sidebar: {
'/start/': [
{
text: '快速开始',
items: [
{ text: '目录', link: '/start/index' },
{ text: '框架', link: '/start/start' },
{ text: '渲染器', link: '/start/Renderer' },
{ text: '适配器', link: '/start/adapter' }
],
}
],
'/event/': [
{
text: '事件',
Expand All @@ -27,13 +82,38 @@ export default defineConfig({
{
text: '插件开发',
items: [
{ text: 'elements', link: '/develop/elements' },
{ text: '#karin', link: '/develop/karin' },
{ text: 'YamlEditor', link: '/develop/YamlEditor' },
{ text: '插件编写', link: '/develop/plugin' },
{ text: '目录', link: '/develop/index' },
{ text: '插件规范', link: '/develop/standard' },
{ text: '开发插件', link: '/develop/plugin' },
{ text: '开发插件包', link: '/develop/plugins' }
]
}
],
'/utils/': [
{
text: '开发工具',
items: [
{ text: 'karin', link: '/utils/karin' },
{ text: 'segment', link: '/utils/segment' },
{ text: 'logger', link: '/utils/logger' },
{ text: 'common', link: '/utils/common' },
{ text: 'redis', link: '/utils/redis' },
{ text: 'update', link: '/utils/update' },
{ text: 'YamlEditor', link: '/utils/YamlEditor' },
{ text: 'Renderer', link: '/utils/Renderer' }
]
}
]
],
'/api/': [
{
text: 'Api',
items: [
{ text: '目录', link: '/api/index' },
{ text: 'kritor', link: '/api/kritor' },
{ text: 'OneBot11', link: '/api/OneBot11' }
],
}
],
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/KarinJS/Karin' }
Expand Down
File renamed without changes.
Empty file added docs/api/OneBot11.md
Empty file.
Empty file added docs/api/index.md
Empty file.
Empty file added docs/api/kritor.md
Empty file.
15 changes: 10 additions & 5 deletions docs/develop/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 编写插件


## 目录

[普通插件编写](./plugin.md)
[插件包编写](./plugins.md)

Expand All @@ -19,20 +19,21 @@
> 推荐安装 `ESLint` 扩展插件进行语法格式检查`(需安装开发依赖,pnpm install)`
## 命名规范
- 单个js插件:请尽量使用英文进行命名,方便开发者跟踪日志。

- 单个js插件:请使用英文进行命名,方便开发者跟踪日志。
- 插件包:要求以 `kritor-plugin-` 开头,后面跟上插件名,如 `kritor-plugin-hello-world`
- 可在仓库标签添加 `karin``karin-plugin` 等标签,方便用户搜索。
- `plugins`目录只识别以 `kritor-plugin-` 开头的文件夹


### 温馨提示

- 只有附带 `index.js` 文件在插件包根目录,才会被视为插件包
- 如不存在 `apps` 目录,则只会加载 `index.js` 文件
- 如存在 `apps` 目录,则会加载 `apps` 目录下所有的 `js` 文件、根目录的`index.js`

## 插件包目录参考结构

```
```md
kritor-plugin-hello-world
├── apps
│ ├── app1.js
Expand All @@ -44,17 +45,21 @@ kritor-plugin-hello-world
└── package.json

```

## #karin

在模板仓库下,有这么一段代码

```js
import { plugin, segment } from '#Karin'
```

`#Karin` 是一个别名,指向 `./lib/index.js` 文件。
此文件为入口文件,开发者无需像以下这样引入模块:

```js
import segment from './lib/bot/segment.js'
import plugin from './lib/plugins/plugin.js'
```
详情请查看 [开发工具](./karin.md) 文档

详情请查看 [开发工具](../utils/index.md) 文档
160 changes: 0 additions & 160 deletions docs/develop/karin.md

This file was deleted.

7 changes: 4 additions & 3 deletions docs/develop/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
打开[模板仓库](https://github.com/KarinJS/karin-plugin-template)

## 克隆模板仓库

点击`Use this template``使用此模板`按钮,创建自己的仓库。
![](https://cdn.jsdelivr.net/gh/Zyy955/imgs/img/202404121412587.png)
![202404121412587](https://cdn.jsdelivr.net/gh/Zyy955/imgs/img/202404121412587.png)

填写仓库名称,描述,选择是否公开。
![](https://cdn.jsdelivr.net/gh/Zyy955/imgs/img/202404121414580.png)
![202404121414580](https://cdn.jsdelivr.net/gh/Zyy955/imgs/img/202404121414580.png)

## 克隆仓库到本地

以下命令,在karin根目录执行

```bash
git clone https://github.com/karinjs/karin-plugin-template.git ./plugins/karin-plugin-template.
```
Expand All @@ -29,4 +31,3 @@ pnpm install --filter=karin-plugin-template
```bash
node . --dev
```

Loading

0 comments on commit b3552fb

Please sign in to comment.