Skip to content

Commit 1f0f4f7

Browse files
chore: 更新开发文档、脚本等资料
- 文档 - 调整章节顺序 - 强调`make copy` - 指出`make doc`的结果是`bithesis.pdf` - MacOS → macOS - 改进 Windows 开发指引,原先有错误,例如 Git Bash 其实并不提供 GNU make - `.gitignore` - 删除重复的`templates/.gitignore` - 忽略 markdown 宏包生成的 lua bridge (#470) - `Makefile` - 删除无用的 `$LATEX` - 补全`.PHONY` - `latexmk -c && latexmk` → `latexmk -gg`,这样更清楚 - `bash` → `sh`,这样更通用 - `the-graduates-handbook/` → `handbook/`,因为本科、硕博都是这里,并非仅仅“graduate” - [check-shebang-scripts-are-executable](https://github.com/pre-commit/pre-commit-hooks/tree/main?tab=readme-ov-file#check-shebang-scripts-are-executable)
1 parent bcae36c commit 1f0f4f7

32 files changed

+85
-355
lines changed

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/upload-artifact@v4
3131
with:
3232
name: handbooks
33-
path: "the-graduates-handbook/*.pdf"
33+
path: "handbook/*.pdf"
3434
- name: Upload *.cls for later usage.
3535
uses: actions/upload-artifact@v4
3636
with:
@@ -170,18 +170,18 @@ jobs:
170170
uses: actions/download-artifact@v4
171171
with:
172172
name: handbooks
173-
path: the-graduates-handbook
173+
path: handbook
174174
- name: Upload undergraduate-handbook
175175
uses: svenstaro/upload-release-action@v2
176176
with:
177177
repo_token: ${{ secrets.GITHUB_TOKEN }}
178-
file: the-graduates-handbook/undergraduate-handbook.pdf
178+
file: handbook/undergraduate-handbook.pdf
179179
tag: ${{ github.ref }}
180180
- name: Upload graduate-handbook
181181
uses: svenstaro/upload-release-action@v2
182182
with:
183183
repo_token: ${{ secrets.GITHUB_TOKEN }}
184-
file: the-graduates-handbook/graduate-handbook.pdf
184+
file: handbook/graduate-handbook.pdf
185185
tag: ${{ github.ref }}
186186

187187
upload_to_ctan:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*.pdf
1616
*.hd
1717
*.sty
18+
*.luabridge.lua
1819

1920
## Intermediate documents:
2021
*.dvi

DEVELOPMENT.md

+49-43
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,76 @@
11
# 开发者指南
22

3-
## 任务管理
3+
> [!TIP]
4+
>
5+
> 本项目采用 [GitHub Projects](https://github.com/BITNP/BIThesis/projects) 进行任务管理。
6+
> 你可以每次选择其中的一个小的 TODO 进行开发;来帮助项目一点一点前进。
47
5-
本项目采用 [GitHub Projects](https://github.com/BITNP/BIThesis/projects) 进行任务管理。
6-
你可以每次选择其中的一个小的 TODO 进行开发;来帮助项目一点一点前进。
8+
## 本地开发
79

8-
## 开发命令
10+
一般开发需求分为三种:
911

10-
Makefile 主要针对 Linux 和 MacOS 开发者;如果你使用 Windows 开发,可以使用 Git Bash 或 Cygwin,不过偶尔可能需要手动执行 Makefile 中具体的命令。
12+
- 修改 `templates/` 中某个模板
1113

12-
当然,也欢迎你贡献更通用的开发脚本
14+
例:改进`ref.bib`中的示例,在 `main.tex` 中补充注释
1315

14-
### 生成 `.cls` 文件
16+
- 修改 `bithesis.dtx` 文件
1517

16-
```Bash
17-
make cls
18-
```
18+
例:添加新命令,更改 `\BITSetup` 选项。
1919

20-
### 生成宏包手册
20+
- 修改其他文件。
2121

22-
```Bash
23-
make doc
24-
```
22+
> [!TIP]
23+
>
24+
> Windows 开发者若运行 Makefile 遇到问题,请参考[后文](#Windows)
2525
26-
### 本地开发
26+
### 修改 `templates/` 中某个模板
2727

28-
一般开发需求分为三个部分
28+
如果改动仅仅涉及某个模板,那么相对简单一些
2929

30-
- 修改 `bithesis.dtx` 文件
31-
- 修改 `templates/` 中某个模板
32-
- 修改其他文件
30+
1. 初次开发前,运行 `make copy`,这会生成 `*.cls` 并更新到 `templates/`
31+
2. 编辑模板
32+
3. 测试,确保你的改动能够正确编译;并且不会影响到其他效果
3333

34-
#### bithesis.dtx 开发流程
34+
### 修改 `bithesis.dtx` 文件
3535

36-
1. 如果需求涉及到添加新的命令,可以先在 `templates/` 中进行具体的实现。
37-
2. 然后,将实现的代码拷贝到 `bithesis.dtx`
38-
3. 然后运行 `make copy` 将新的 `*.cls` 更新到 `templates/` 下。
39-
4. 不要忘记更新 `bithesis.dtx` 中的手册部分,添加相应说明。
40-
5. 运行 `make doc` 编译手册。
41-
6. 运行测试,确保你的改动不会影响到其他功能。
36+
1. 编辑 `bithesis.dtx`
37+
2. 运行 `make copy`,这会生成新的 `*.cls` 并更新到 `templates/` 下。
38+
3. 更新文档(`bithesis-doc.tex` 以及 `bithesis.dtx` 中的注释),然后运行 `make doc` 编译出手册`bithesis.pdf`
39+
4. 测试,确保你的改动不会影响到其他功能。
4240

43-
#### 修改 `templates/` 中模板的行为
41+
> [!TIP]
42+
>
43+
> 如果要添加新命令,可以先在 `templates/` 中具体实现,再拷贝到 `bithesis.dtx`
4444
45-
如果改动仅仅涉及某个模板,那么相对简单一些:
45+
## 参考资料
46+
47+
- 本项目采用 LaTeX3,可以参考 [LaTeX3: Programming in LaTeX with Ease](https://www.alanshawn.com/tech/2020/10/04/latex3-tutorial.html)[expl3 的文档](https://www.latex-project.org/help/documentation/)等。
48+
- 关于模板,[fduthesis 项目代码](https://github.com/stone-zeng/fduthesis)有很多最佳实践,可以参考。
49+
- 样式部分则应参考[研究生院](https://grd.bit.edu.cn/xwgz/xwgz2/wjxz_xwgz/)和教务部的相关文件和通知。
4650

47-
1. 直接修改模板中的样式
48-
2. 进行测试,确保你的改动能够正确编译;并且不会影响到其他效果。
51+
## Makefile 的进一步介绍
4952

50-
#### 辅助命令
53+
### Windows
5154

52-
由于我们常常需要实时预览代码编译的效果,而 LaTeX 本身没有提供实时编译的功能。
53-
因此我们常常需要来回运行 `make copy``latexmk` 以达成实时编译的效果。
55+
Makefile 主要针对 Linux 和 macOS 开发者;Windows 开发者要确保至少有:
5456

55-
因此 Makefile 里面提供了一些辅助开发的命令(以 `dev-`)开头。
56-
可以帮助你自动化以上流程。
57+
- GNU make——可按 [ScoopInstaller/Main: `make.json`](https://github.com/ScoopInstaller/Main/blob/master/bucket/make.json) 中的 `url` 下载。
58+
- GNU coreutils——可使用内置了 coreutils 的 Git Bash 或 Cygwin,或者[安装 uutils-coreutils](https://uutils.github.io/coreutils/docs/installation.html#windows)
59+
60+
当然,也欢迎你贡献更通用的开发脚本。
61+
62+
### 辅助命令
63+
64+
我们常常需要实时预览代码编译的效果,而 LaTeX 本身没有提供实时编译的功能,导致我们要来回运行 `make copy``latexmk`
65+
66+
为此 Makefile 提供了一些辅助命令,以 `dev-`开头,可以帮助你自动化以上流程。
5767

5868
或者你可以使用类似 `rg --files | entr make copy` 以及 `rg --files | entr latexmk` 来达到
5969
「代码修改后立即重新编译」的效果。
6070

61-
## 参考资料
62-
63-
- 本项目 LaTeX3,因此可以参考的手册包括 [expl3 的文档](https://www.latex-project.org/help/documentation/)
64-
- [fduthesis 项目代码](https://github.com/stone-zeng/fduthesis)有很多最佳实践,可以参考。
65-
- 样式部分,应该参考研究生院和教务部的相关文件和通知。
71+
(这些命令未必适用于 Windows,可能要手动用 [watchexec](https://watchexec.github.io/) 等替代。)
6672

67-
## 单元测试和回归测试
73+
### 单元测试和回归测试
6874

6975
运行 `make test` 将对所有的模板进行编译测试(同样被用于 GitHub Actions)。
7076

@@ -75,13 +81,13 @@ make doc
7581
- [diff-pdf](https://vslavik.github.io/diff-pdf/)
7682
- [jq](https://jqlang.github.io/jq/)(仅用 Zsh 时需要)
7783

78-
## 打包
84+
### 打包
7985

8086
- `make overleaf version=X.X.X` 可以生成上传 overleaf 所需要的 zip 文件。
8187
- `make pkg` 可以生成上传 CTAN 所需要的 zip 文件。若已有手册而不想重新编译,可 `make pkg-only`。(同样被用于 GitHub Actions)
8288
- `make grad version=X.X.X` 可以生成用作研究生院官网附件的 zip 文件。
8389

84-
## 上传 Overleaf 与更新
90+
### 上传 Overleaf 与更新
8591

8692
> [!NOTE]
8793
> Overleaf 链接已利用 [`overleaf.com/docs` API](https://www.overleaf.com/devs) 自动指向最新发布版,不再需要手动更新。

Makefile

+29-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# 以下命令仅保证能在 Linux 或 MacOS 环境下执行。
1+
# 以下命令仅保证能在 Linux 或 macOS 环境下执行。
22
# 如果你是 Windows 用户,可以使用 Git Bash 或者 Cygwin 来执行;
33
# 或者可以考虑将此脚本移植为 PowerShell。
44
PACKAGE = bithesis
55

6-
LATEX = xelatex
7-
86
SOURCES = $(PACKAGE).ins $(PACKAGE).dtx
97
CLSFILE = dtx-style.sty bitreport.cls bithesis.cls bitbeamer.cls
108

@@ -21,30 +19,37 @@ else
2119
endif
2220

2321

24-
.PHONY: all cls doc clean FORCE_MAKE copy pkg pkg-only
22+
.PHONY: all FORCE_MAKE
2523

2624
$(PACKAGE).pdf: cls FORCE_MAKE
2725
@$(LATEXMK) -xelatex $(PACKAGE).dtx
2826

2927
$(CLSFILE): $(SOURCES)
3028
yes y | xetex $(PACKAGE).ins
3129

30+
.PHONY: cls
3231
cls: $(CLSFILE)
3332

33+
.PHONY: doc
3434
doc: $(PACKAGE).pdf
3535

36+
.PHONY: viewdoc
3637
viewdoc: doc
3738
$(LATEXMK) -pv $(PACKAGE).dtx
3839

40+
.PHONY: clean
3941
clean:
4042
$(LATEXMK) -c $(PACKAGE).dtx
4143
-rm -rf *.glo $(CLSFILE)
4244

45+
.PHONY: clean-dist
4346
clean-dist:
4447
-rm -rf $(PACKAGE).pdf
4548

49+
.PHONY: clean-all
4650
clean-all: clean clean-dist FORCE_MAKE
4751

52+
.PHONY: test
4853
test: doc copy FORCE_MAKE
4954
cd $(SCAFFOLDDIR)/undergraduate-thesis && latexmk && cd ..
5055
cd $(SCAFFOLDDIR)/paper-translation && latexmk && cd ..
@@ -55,12 +60,14 @@ test: doc copy FORCE_MAKE
5560
cd $(SCAFFOLDDIR)/presentation-slide && latexmk && cd ..
5661
cd $(TESTDIR)/doctor-thesis && latexmk && cd ..
5762
cd $(TESTDIR)/autorefs && latexmk && cd ..
58-
cd ./the-graduates-handbook && latexmk && latexmk -c \
59-
&& GRADUATE=true latexmk && cd ..
63+
cd ./handbook && latexmk \
64+
&& GRADUATE=true latexmk -gg && cd ..
6065

66+
.PHONY: regression-test
6167
regression-test: cls
6268
$(REGRESSION_TEST_COMMAND)
6369

70+
.PHONY: copy
6471
copy: cls
6572
cp bithesis.cls $(SCAFFOLDDIR)/undergraduate-thesis
6673
cp bithesis.cls $(SCAFFOLDDIR)/undergraduate-thesis-en
@@ -69,11 +76,12 @@ copy: cls
6976
cp bithesis.cls $(SCAFFOLDDIR)/reading-report
7077
cp bithesis.cls $(TESTDIR)/doctor-thesis
7178
cp bithesis.cls $(TESTDIR)/autorefs
72-
cp bithesis.cls ./the-graduates-handbook
79+
cp bithesis.cls ./handbook
7380
cp bitreport.cls $(SCAFFOLDDIR)/lab-report
7481
cp bitbeamer.cls $(SCAFFOLDDIR)/presentation-slide
7582

7683
# Generate scaffolds for overleaf
84+
.PHONY: overleaf
7785
overleaf: doc FORCE_MAKE
7886
# if $version is not specified, alert the user.
7987
@if [ -z "$$version" ]; then \
@@ -86,33 +94,38 @@ overleaf: doc FORCE_MAKE
8694
make copy
8795
mkdir overleaf
8896
ls templates | \
89-
xargs -I {} bash -c \
97+
xargs -I {} sh -c \
9098
"cp -r ./templates/{} overleaf && cp $(PACKAGE).pdf ./overleaf/{} && (cd overleaf/{}/ && zip -r ../BIThesis-{}-v$(version).zip .)"
9199

100+
.PHONY: dev
92101
dev:
93102
ls bithesis.dtx | entr -s 'yes y | make doc && make copy'
94103

104+
.PHONY: dev-doc
95105
dev-doc:
96106
ls bithesis.dtx | entr -s 'make clean-all && yes y | make doc && open bithesis.pdf'
97107

108+
.PHONY: pkg-only
98109
pkg-only:
99110
rm -rf ./bithesis ./bithesis.zip
100111
mkdir bithesis
101112
cp bithesis.ins bithesis.dtx bithesis.pdf ./README*.md ./contributing*.md ./bithesis
102113
mv ./bithesis/README-bithesis.md ./bithesis/README.md
103114
zip -r bithesis.zip bithesis
104115

116+
.PHONY: pkg
105117
pkg: doc pkg-only
106118

107119
GRAD_DEST_DIR = ./BIThesis-graduate-thesis-template
108120

121+
.PHONY: handbooks
109122
handbooks: copy FORCE_MAKE
110-
cd the-graduates-handbook && latexmk -c \
111-
&& GRADUATE=true latexmk && mv main.pdf graduate-handbook.pdf \
112-
&& latexmk -c \
113-
&& latexmk && mv main.pdf undergraduate-handbook.pdf && cd -
123+
cd handbook \
124+
&& GRADUATE=true latexmk -gg && mv main.pdf graduate-handbook.pdf \
125+
&& latexmk -gg && mv main.pdf undergraduate-handbook.pdf && cd -
114126

115127
# 用于提供给研究生院
128+
.PHONY: grad
116129
grad: doc copy handbooks FORCE_MAKE
117130
# if $version is not specified, alert the user.
118131
@if [ -z "$$version" ]; then \
@@ -125,14 +138,15 @@ grad: doc copy handbooks FORCE_MAKE
125138
mkdir ${GRAD_DEST_DIR}-${version}
126139
cp -r $(SCAFFOLDDIR)/graduate-thesis/ ${GRAD_DEST_DIR}-${version}/graduate-thesis/
127140
cp ./bithesis.pdf ${GRAD_DEST_DIR}-${version}/'3-详细配置手册'.pdf
128-
cp ./the-graduates-handbook/graduate-handbook.pdf ${GRAD_DEST_DIR}-${version}/'2-快速使用手册'.pdf
141+
cp ./handbook/graduate-handbook.pdf ${GRAD_DEST_DIR}-${version}/'2-快速使用手册'.pdf
129142
(cd ${GRAD_DEST_DIR}-${version}/graduate-thesis/ && zip -rm ../"1-BIThesis-论文模板-${version}".zip . )
130143
rmdir ${GRAD_DEST_DIR}-${version}/graduate-thesis
131144
zip -r ${GRAD_DEST_DIR}-${version}.zip ${GRAD_DEST_DIR}-${version}
132145

133146
UNDERGRAD_DEST_DIR = ./BIThesis-undergraduate-thesis-templates
134147

135148
# 用于提供给教务部
149+
.PHONY: undergrad
136150
undergrad: doc copy handbooks FORCE_MAKE
137151
@if [ -z "$$version" ]; then \
138152
echo -e "\e[32mPlease specify the version of the template you want to generate.\e[0m"; \
@@ -148,7 +162,7 @@ undergrad: doc copy handbooks FORCE_MAKE
148162
cp -r $(SCAFFOLDDIR)/undergraduate-thesis-en/ ${UNDERGRAD_DEST_DIR}-${version}/undergraduate-thesis-en/
149163
cp -r $(SCAFFOLDDIR)/paper-translation/ ${UNDERGRAD_DEST_DIR}-${version}/paper-translation/
150164
cp ./bithesis.pdf ${UNDERGRAD_DEST_DIR}-${version}/'4-详细配置手册'.pdf
151-
cp ./the-graduates-handbook/undergraduate-handbook.pdf ${UNDERGRAD_DEST_DIR}-${version}/'5-快速使用手册'.pdf
165+
cp ./handbook/undergraduate-handbook.pdf ${UNDERGRAD_DEST_DIR}-${version}/'5-快速使用手册'.pdf
152166
(cd ${UNDERGRAD_DEST_DIR}-${version}/undergraduate-thesis/ && zip -rm ../"1-BIThesis-本科毕设论文模板-${version}".zip . )
153167
(cd ${UNDERGRAD_DEST_DIR}-${version}/undergraduate-thesis-en/ && zip -rm ../"2-BIThesis-本科毕设论文模板(全英文)-${version}".zip . )
154168
(cd ${UNDERGRAD_DEST_DIR}-${version}/paper-translation/ && zip -rm ../"3-BIThesis-本科毕设外文翻译-${version}".zip . )
@@ -157,9 +171,9 @@ undergrad: doc copy handbooks FORCE_MAKE
157171
rmdir ${UNDERGRAD_DEST_DIR}-${version}/paper-translation
158172
zip -r ${UNDERGRAD_DEST_DIR}-${version}.zip ${UNDERGRAD_DEST_DIR}-${version}
159173

174+
.PHONY: examples
160175
examples: cls
161176
cp bithesis.cls $(EXAMPLEDIR)/cover/
162177
cp bithesis.cls $(EXAMPLEDIR)/publications/
163178
cd $(EXAMPLEDIR)/cover && latexmk && cd -
164179
cd $(EXAMPLEDIR)/publications && latexmk && cd -
165-

bithesis-doc.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ \subsubsection{封面选项} \label{sec:cover}
600600

601601
配置此选项以在部分模板封面中使用“华文细黑”,保证与 Word 模板中的字体一致。
602602

603-
在 Windows 和 MacOS 中,该字体已经安装;在 Linux 中一般需要用户自行安装(如果你是 WSL 用户,可参照\ref{sec:word-fonts}直接使用 Windows 下的字体)。
603+
在 Windows 和 macOS 中,该字体已经安装;在 Linux 中一般需要用户自行安装(如果你是 WSL 用户,可参照\ref{sec:word-fonts}直接使用 Windows 下的字体)。
604604
\end{function}
605605

606606
\begin{function}{cover/dilimiter}
@@ -1245,7 +1245,7 @@ \subsubsection{其他配置}
12451245
\textit{此选项一般不需要用户自行修改。}
12461246

12471247
本科生毕业设计模板(全英文专业)需要设置 Arial 字体。
1248-
在 Windows 和 MacOS 中,该字体已经安装;在 Linux 中需要用户自行安装(如果你是 WSL 用户,可参照\ref{sec:word-fonts}直接使用 Windows 下的字体)。
1248+
在 Windows 和 macOS 中,该字体已经安装;在 Linux 中需要用户自行安装(如果你是 WSL 用户,可参照\ref{sec:word-fonts}直接使用 Windows 下的字体)。
12491249
\end{function}
12501250

12511251
\begin{function}[added=2023-04-22, updated=2024-05-13]{misc/tabularFontSize}

bithesis.luabridge.lua

-1
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/convert-cover.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)