Skip to content

Commit

Permalink
Move samples to testfiles (#29)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Alexara Wu <alexarawu@outlook.com>
  • Loading branch information
LogCreative and AlexaraWu authored Dec 20, 2023
1 parent e1f4a79 commit d3266ce
Show file tree
Hide file tree
Showing 43 changed files with 111 additions and 30 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ jobs:
with:
scheme: full
run: |
apk add font-noto-cjk
git config --global --add safe.directory /github/workspace
apk add zip diffutils font-noto-cjk
git config --global --add safe.directory /home/runner/work/SJTUTeX/SJTUTeX
cd sjtutex && l3build ctan
name: build package with l3build
- name: prepare upload artifacts
run: |
sudo rm -r sjtutex/build/distrib/tds/*/
sudo unzip -d sjtutex/build/distrib/tds/ sjtutex/build/distrib/tds/sjtutex.tds.zip
sudo rm sjtutex/build/distrib/tds/sjtutex.tds.zip
sudo rm sjtutex/doc/sjtutex.pdf
run: sudo rm sjtutex/build/distrib/tds/sjtutex.tds.zip
- uses: actions/upload-artifact@v3
with:
path: |
Expand All @@ -39,6 +35,6 @@ jobs:
- uses: actions/upload-artifact@v3
with:
path: |
sjtutex/doc/
sjtutex/build/result
name: samples
name: upload build samples artifacts
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
scheme: full
run: |
apk add zip diffutils font-noto-cjk
git config --global --add safe.directory /github/workspace
git config --global --add safe.directory /home/runner/work/SJTUTeX/SJTUTeX
cd sjtutex && l3build ctan
name: build package
- uses: actions/create-release@latest
Expand All @@ -37,7 +37,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: sjtutex/doc/sjtutex.pdf
asset_path: sjtutex/sjtutex.pdf
asset_name: sjtutex.pdf
asset_content_type: application/pdf
- name: add sjtutex.tds.zip
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build/
*.zip

# sjtutex
sjtutex/doc/*.pdf
sjtutex/*.pdf
sjtutex/support/*.id

## Editors
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

SOURCE_DIR=sjtutex

all: build
all: build-ctan

# Clean all temporary files and generated files
clean:
Expand All @@ -18,8 +18,15 @@ build-ctan:
build:
cd $(SOURCE_DIR) && l3build doc

test:
cd $(SOURCE_DIR) && l3build check

# For TeX Live/MacTeX users to install the package
install:
cd $(SOURCE_DIR) && l3build install

# Generate `.sty` files and copy resources
generate:
cd $(SOURCE_DIR) && l3build unpack && cd ..

.PHONY: build build-ctan format clean generate
.PHONY: build test build-ctan install clean generate
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,56 @@ cd sjtutex
l3build install
```

也可以将[发布区](https://github.com/sjtug/SJTUTeX/releases/latest)`sjtutex.tds.zip` 手动解压到发行版的 TDS 目录下。
也可以将 [发布区](https://github.com/sjtug/SJTUTeX/releases/latest) `sjtutex.tds.zip` 手动解压到发行版的 TDS 目录下。

## 开发指南

文档类主要代码在 `sjtutex.dtx` 中,需要解包之后才能够使用
开发主要在 `sjtutex` 文件夹中进行,生成发布包会进行解包、测试、文档等全部流程

```bash
cd sjtutex
l3build unpack # 解包
l3build doc # 编译全部示例及文档
l3build doc # 文档
l3build check # 测试
l3build ctan # 生成发布包
```

文档类还含有多个示例(比如 `sample-thesis-zh`),主要存放于 `doc` 文件夹中(支持文件存放于 `support` 文件夹),编译单个示例 `<sample>` 可使用
### 解包

```bash
l3build doc <sample>
文档类主要代码在 `source/sjtutex.dtx` 中,需要解包之后才能够使用。
```
l3build unpack
```
解包结果将置于 `build/unpacked`(含有 dtx 文件)和 `build/local`(不含 dtx 文件) 文件夹下。

仅编译文档类文档可以使用
### 文档

`source/sjtutex.dtx` 编译出文档类文档 `sjtutex.pdf` 可以使用

```bash
l3build doc sjtutex
```
l3build doc
```

> 请注意文档类文档 `sjtutex.pdf` 的正确编译需要使用 Noto CJK 字体(即 `ctex` 字体配置中的 `fontset=ubuntu`)。
在您提交 PR 时,GitHub Action 会自动构建文档 PDF。
### 测试

文档类还含有多个测试用例(比如 `sample-thesis-zh`),主要存放于 `testfiles` 文件夹中(支持文件存放于 `testfiles/support` 文件夹)。

测试全部示例使用
```
l3build check
```

上面的过程默认隐藏编译细节。为了查看单个测试用例 `<sample>` 的编译细节,可以使用

```
l3build check <sample>
```

测试的 PDF 结果生成于 `build/result` 文件夹。

> 请使用尽可能新版本的 [l3build](https://github.com/latex3/l3build),更多细节请参见 [l3build 文档](https://mirrors.sjtug.sjtu.edu.cn/CTAN/macros/latex/contrib/l3build/l3build.pdf)`texdoc l3build`)。
## 软件许可证

Expand Down
44 changes: 38 additions & 6 deletions sjtutex/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@ sourcefiledir = "source"
sourcefiles = {"sjtutex.dtx","sjtu-vi-*.pdf"}
installfiles = {"*.cls","*.def","*.pdf"}

docfiledir = "doc"

typesetexe = "xelatex"
typesetfiles = {"sample-*.tex","sjtutex.dtx"}
typesetsuppfiles = {"ctxdoc.cls","common-*.tex","ref.bib"}
typesetsuppfiles = {"ctxdoc.cls"}

bibtexexe = "bibtex"
biberexe = "biber"
biberopts = "--quiet"

unpackexe = "luatex"
unpackfiles = {"sjtutex.dtx"}
unpacksuppfiles = {"sjtutex.id"}
gitverfiles = {"sjtutex.dtx"}

checkruns = 3
checkengines = {"luatex","xetex"} -- do not reorder this, related to runtest_tasks()
checkopts = "-file-line-error -halt-on-error -interaction=nonstopmode"
recordstatus = true
lvtext = ".tex"
xdvext = ".xdv"

packtdszip = true

tdslocations = {
"tex/latex/sjtutex/fd/sjtu-*-font-*.def",
"tex/latex/sjtutex/font/sjtu-*-font-*.def",
"tex/latex/sjtutex/lang/sjtu-lang-*.def",
"tex/latex/sjtutex/name/sjtu-name-*.def",
"tex/latex/sjtutex/scheme/sjtu-scheme-*.def",
"tex/latex/sjtutex/vi/sjtu-vi-*.pdf"
}

excludefiles = {"*~","sample-*.tex","sample-*.pdf"}

shellescape = os.type == "windows"
and function (s) return s end
or function (s)
Expand Down Expand Up @@ -102,6 +107,33 @@ function tag_hook(tagname)
os.execute("git tag v" .. tagname)
end

-- Similar to dvitopdf()
function xdvtopdf(name, dir)
runcmd(
"xdvipdfmx -E -q " .. name .. xdvext,
dir
)
end

function runtest_tasks(name, run)
if run == 1 and fileexists(testdir .. "/" .. name .. ".bcf") then
return biberexe .. " " .. name .. " " .. biberopts
else
if run == checkruns then
local engine
if not(fileexists(testdir .. "/" .. name .. xdvext)) then
engine = "luatex"
else
engine = "xetex"
xdvtopdf(name, testdir)
end
cp(name .. pdfext,testdir,resultdir)
ren(resultdir, name .. pdfext, name .. "." .. engine .. pdfext)
end
return ""
end
end

null_function = function() return 0 end

unpack_prehook = unpack_prehook or null_function
Expand Down
2 changes: 1 addition & 1 deletion sjtutex/support/ctxdoc.cls
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
{ \use:n }
{
\tl_set:Nn \l__codedoc_tmpa_tl {#1}
\tl_replace_all:Non \l__codedoc_tmpa_tl
\tl_replace_all:Nen \l__codedoc_tmpa_tl
{ \c_catcode_other_space_tl }
{ \fontspec_visible_space: }
\__codedoc_macroname_prefix:o \l__codedoc_tmpa_tl
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-article-zh.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-report-zh.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-thesis-de.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-thesis-en.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-thesis-ja.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
4 changes: 4 additions & 0 deletions sjtutex/testfiles/sample-thesis-zh.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
***************
Compilation 1 of test file completed with exit status 0
Compilation 2 of test file completed with exit status 0
Compilation 3 of test file completed with exit status 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d3266ce

Please sign in to comment.