Skip to content

Commit ac47512

Browse files
committed
docs: add banner.txt support documentation
- Add comprehensive banner.txt usage documentation to README.md and README_en.md - Document variable substitution support in banner.txt - Include examples of compiled output with banner - Resolves #2: 增加对banner.txt的支持 The banner.txt feature was already implemented in webpack.common.js but lacked documentation. Users can now add ASCII art or decorative text that gets inserted as comments in compiled userscripts.
1 parent 52a6a00 commit ac47512

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,42 @@ npm install
118118

119119
![image-20230817004653299](README.assets/image-20230817004653299.png)
120120

121+
## Banner支持
122+
123+
项目支持在编译后的代码中添加自定义banner。在项目根目录的`banner.txt`文件中,你可以添加ASCII艺术字或其他装饰性文本:
124+
125+
```
126+
▗▄▄▄▖▗▖ ▗▖▗▄▄▖ ▗▄▄▄▖ ▗▄▄▖ ▗▄▄▖▗▄▄▖ ▗▄▄▄▖▗▄▄▖▗▄▄▄▖
127+
█ ▝▚▞▘ ▐▌ ▐▌▐▌ ▐▌ ▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
128+
█ ▐▌ ▐▛▀▘ ▐▛▀▀▘ ▝▀▚▖▐▌ ▐▛▀▚▖ █ ▐▛▀▘ █
129+
█ ▐▌ ▐▌ ▐▙▄▄▖▗▄▄▞▘▝▚▄▄▖▐▌ ▐▌▗▄█▄▖▐▌ █
130+
```
131+
132+
编译时,banner内容会被自动插入到油猴脚本头部注释中,支持以下变量替换:
133+
- `${name}` - 项目名称
134+
- `${version}` - 版本号
135+
- `${description}` - 项目描述
136+
- `${author}` - 作者信息
137+
- `${repository}` - 仓库地址
138+
- `${namespace}` - 命名空间
139+
- `${document}` - 文档地址
140+
141+
编译后的效果:
142+
```javascript
143+
// ==UserScript==
144+
// @name my-project
145+
// @version 1.0.0
146+
// ...
147+
// ==/UserScript==
148+
149+
// ▗▄▄▄▖▗▖ ▗▖▗▄▄▖ ▗▄▄▄▖ ▗▄▄▖ ▗▄▄▖▗▄▄▖ ▗▄▄▄▖▗▄▄▖▗▄▄▄▖
150+
// █ ▝▚▞▘ ▐▌ ▐▌▐▌ ▐▌ ▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
151+
// █ ▐▌ ▐▛▀▘ ▐▛▀▀▘ ▝▀▚▖▐▌ ▐▛▀▚▖ █ ▐▛▀▘ █
152+
// █ ▐▌ ▐▌ ▐▙▄▄▖▗▄▄▞▘▝▚▄▄▖▐▌ ▐▌▗▄█▄▖▐▌ █
153+
154+
// 你的代码...
155+
```
156+
121157
然后就可以开心的写代码了,在编写代码的时候你可以使用`npm`命令为项目添加依赖,对于一个稍微复杂点的脚本而言很可能会引用外部的依赖:
122158

123159
```bash

README_en.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,42 @@ In addition to variable substitution, all other content will be preserved as is,
131131

132132
![image-20230817004653299](README.assets/image-20230817004653299.png)
133133

134+
## Banner Support
135+
136+
The project supports adding custom banners to the compiled code. In the `banner.txt` file in the project root directory, you can add ASCII art or other decorative text:
137+
138+
```
139+
▗▄▄▄▖▗▖ ▗▖▗▄▄▖ ▗▄▄▄▖ ▗▄▄▖ ▗▄▄▖▗▄▄▖ ▗▄▄▄▖▗▄▄▖▗▄▄▄▖
140+
█ ▝▚▞▘ ▐▌ ▐▌▐▌ ▐▌ ▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
141+
█ ▐▌ ▐▛▀▘ ▐▛▀▀▘ ▝▀▚▖▐▌ ▐▛▀▚▖ █ ▐▛▀▘ █
142+
█ ▐▌ ▐▌ ▐▙▄▄▖▗▄▄▞▘▝▚▄▄▖▐▌ ▐▌▗▄█▄▖▐▌ █
143+
```
144+
145+
During compilation, the banner content will be automatically inserted into the userscript header comments, supporting the following variable substitutions:
146+
- `${name}` - Project name
147+
- `${version}` - Version number
148+
- `${description}` - Project description
149+
- `${author}` - Author information
150+
- `${repository}` - Repository address
151+
- `${namespace}` - Namespace
152+
- `${document}` - Document address
153+
154+
Compiled result:
155+
```javascript
156+
// ==UserScript==
157+
// @name my-project
158+
// @version 1.0.0
159+
// ...
160+
// ==/UserScript==
161+
162+
// ▗▄▄▄▖▗▖ ▗▖▗▄▄▖ ▗▄▄▄▖ ▗▄▄▖ ▗▄▄▖▗▄▄▖ ▗▄▄▄▖▗▄▄▖▗▄▄▄▖
163+
// █ ▝▚▞▘ ▐▌ ▐▌▐▌ ▐▌ ▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
164+
// █ ▐▌ ▐▛▀▘ ▐▛▀▀▘ ▝▀▚▖▐▌ ▐▛▀▚▖ █ ▐▛▀▘ █
165+
// █ ▐▌ ▐▌ ▐▙▄▄▖▗▄▄▞▘▝▚▄▄▖▐▌ ▐▌▗▄█▄▖▐▌ █
166+
167+
// Your code...
168+
```
169+
134170
Then you can happily start coding. While writing code, you can use the `npm` command to add dependencies to your project. For a slightly more complex script, it is very likely to reference external dependencies:
135171

136172
```bash

0 commit comments

Comments
 (0)