doc-render-sdk 0.0.8 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -1
- package/bin/doc-render-sdk.js +551 -210
- package/dist/_chunks/index-C3VNauf3.d.mts +88 -0
- package/dist/_chunks/index-C3VNauf3.d.mts.map +1 -0
- package/dist/_chunks/plugin-DCF0RLbi.mjs +228 -0
- package/dist/_chunks/plugin-DCF0RLbi.mjs.map +1 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +32 -3070
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/index.d.mts +2 -0
- package/dist/plugin/index.mjs +3 -0
- package/package.json +30 -13
package/README.md
CHANGED
|
@@ -66,7 +66,132 @@ docSdk.render('#app');
|
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
##
|
|
69
|
+
## 🔧 Vite 插件
|
|
70
|
+
|
|
71
|
+
doc-render-sdk 提供了 Vite 插件,自动读取 demo 文件源码并注入到全局变量。
|
|
72
|
+
|
|
73
|
+
### 核心特性
|
|
74
|
+
|
|
75
|
+
- ✅ **自动读取源码** - 从 demo 文件自动读取源代码
|
|
76
|
+
- ✅ **零维护成本** - 无需手动维护代码字符串
|
|
77
|
+
- ✅ **单一数据源** - demo 文件即是唯一的代码来源
|
|
78
|
+
- ✅ **自动同步** - 修改 demo 文件,代码展示自动更新
|
|
79
|
+
- ✅ **灵活配置** - 支持自定义配置和预设
|
|
80
|
+
|
|
81
|
+
### 快速使用
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
// vite.config.js
|
|
85
|
+
import { defineConfig } from 'vite';
|
|
86
|
+
import demoCodePlugin from 'doc-render-sdk/plugin';
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
plugins: [
|
|
90
|
+
demoCodePlugin({
|
|
91
|
+
include: 'src/main.js',
|
|
92
|
+
demoPattern: '/demo/',
|
|
93
|
+
debug: true
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 预设配置
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
import demoCodePlugin, { presets } from 'doc-render-sdk/plugin';
|
|
103
|
+
|
|
104
|
+
// 默认配置
|
|
105
|
+
demoCodePlugin(presets.default)
|
|
106
|
+
|
|
107
|
+
// 严格模式
|
|
108
|
+
demoCodePlugin(presets.strict)
|
|
109
|
+
|
|
110
|
+
// 宽松模式(支持下划线命名)
|
|
111
|
+
demoCodePlugin(presets.loose)
|
|
112
|
+
|
|
113
|
+
// TypeScript 项目
|
|
114
|
+
demoCodePlugin(presets.typescript)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
详细文档请查看 [插件文档](./src/plugin/README.md)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📚 Playground 文档
|
|
122
|
+
|
|
123
|
+
- [项目说明](./playground/README.md) - Playground 项目概览
|
|
124
|
+
- [组件添加指南](./playground/HOW_TO_ADD_COMPONENT.md) - 如何添加新组件
|
|
125
|
+
- [项目总结](./playground/SUMMARY.md) - 完整的项目总结
|
|
126
|
+
|
|
127
|
+
### 自动化工具
|
|
128
|
+
|
|
129
|
+
- [Vite 插件文档](./playground/VITE_PLUGIN_README.md) - vite-plugin-demo-code 详细说明
|
|
130
|
+
- [代码自动生成](./playground/DEMO_CODE_AUTO_GENERATION.md) - Demo 代码自动生成原理
|
|
131
|
+
- [重要变更](./playground/CHANGES.md) - 最新变更说明
|
|
132
|
+
|
|
133
|
+
## 🔧 Vite 插件:vite-plugin-demo-code
|
|
134
|
+
|
|
135
|
+
专为 doc-render-sdk 设计的 Vite 插件,自动读取 demo 文件源码并注入到全局变量。
|
|
136
|
+
|
|
137
|
+
### 核心特性
|
|
138
|
+
|
|
139
|
+
- ✅ **自动读取源码** - 从 demo 文件自动读取源代码
|
|
140
|
+
- ✅ **零维护成本** - 无需手动维护代码字符串
|
|
141
|
+
- ✅ **单一数据源** - demo 文件即是唯一的代码来源
|
|
142
|
+
- ✅ **自动同步** - 修改 demo 文件,代码展示自动更新
|
|
143
|
+
- ✅ **灵活配置** - 支持自定义配置和预设
|
|
144
|
+
|
|
145
|
+
### 快速使用
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// vite.config.js
|
|
149
|
+
import demoCodePlugin from './vite-plugin-demo-code.js';
|
|
150
|
+
|
|
151
|
+
export default defineConfig({
|
|
152
|
+
plugins: [
|
|
153
|
+
demoCodePlugin() // 使用默认配置
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 自定义配置
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
demoCodePlugin({
|
|
162
|
+
include: 'src/main.js', // 处理的文件
|
|
163
|
+
demoPattern: '/components/', // Demo 文件路径模式
|
|
164
|
+
globalVar: 'window.__MY_CODES__', // 自定义全局变量名
|
|
165
|
+
debug: true, // 开启调试模式
|
|
166
|
+
transform: (code) => { // 自定义代码转换
|
|
167
|
+
return code.replace(/\/\/.*/g, '');
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 预设配置
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
import demoCodePlugin, { presets } from './vite-plugin-demo-code.js';
|
|
176
|
+
|
|
177
|
+
// 默认配置
|
|
178
|
+
demoCodePlugin(presets.default)
|
|
179
|
+
|
|
180
|
+
// 严格模式
|
|
181
|
+
demoCodePlugin(presets.strict)
|
|
182
|
+
|
|
183
|
+
// 宽松模式(支持下划线命名)
|
|
184
|
+
demoCodePlugin(presets.loose)
|
|
185
|
+
|
|
186
|
+
// TypeScript 项目
|
|
187
|
+
demoCodePlugin(presets.typescript)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
详细文档请查看 [Vite 插件文档](./playground/VITE_PLUGIN_README.md)
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 📚 配置文档
|
|
70
195
|
|
|
71
196
|
### 配置选项
|
|
72
197
|
|