Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/tl_packages
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ----- 1. 编译基础中文文档需要 -----

scheme-minimal

collection-latex
Expand All @@ -15,13 +17,16 @@ biber
biblatex
biblatex-gb7714-2015

# ----- 2. 编译 templates/* 需要 -----

# collection-latexextra
enumitem
fmtcount
multirow
titlesec
xint # indirect
xstring # indirect
mwe # for `example-image*` files

# collection-latexrecommended
booktabs
Expand All @@ -48,3 +53,25 @@ xits

# collection-fontsrecommended
tex-gyre

# Not included in any collection
float

# ----- 3. 编译 handbook 和 bithesis.pdf 需要 -----

# collection-latexextra
adjustbox # indirect
alphalph # indirect
awesomebox
csquotes # indirect
csvsimple # indirect
framed
hypdoc
markdown
menukeys
relsize
was # for upgreek
wrapfig

# Not included in any collection
fancyvrb # indirect
35 changes: 30 additions & 5 deletions scripts/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Compile all projects, used by `make test`."""

from collections.abc import Generator
from dataclasses import dataclass
from os import environ
from pathlib import Path
Expand All @@ -20,13 +21,27 @@


def log(message: str | Any) -> None:
"""Write to stdout and the SUMMARY file."""
"""Write markdown `message` to stdout and the SUMMARY file."""
if not isinstance(message, str):
message = str(message)

print(message)
print(message, end="\n\n")
with SUMMARY.open("a", encoding="utf-8") as f:
f.write(message + "\n")
f.write(message + "\n\n")


def parse_log(file: Path) -> Generator[str]:
"""Collect key errors from a log file."""
with file.open(encoding="utf-8") as f:
for line in f:
if line.startswith("!"):
yield line.strip()


def collect_errors(directory: Path) -> Generator[tuple[Path, Generator[str]]]:
"""Read all log files in the `directory` and collect key errors."""
for file in directory.glob("*.log"):
yield file.relative_to(directory), parse_log(file)


@dataclass
Expand Down Expand Up @@ -68,9 +83,19 @@ def execute(self) -> CalledProcessError | None:
env=None if self.env is None else {**environ, **self.env},
check=True,
)
except CalledProcessError as error:
except CalledProcessError as running_error:
log(f"💥{self.icon} 无法编译 {self.name}。")
return error
for file, errors in collect_errors(self.directory):
log(
"\n".join(
[
f"- `{file}`:",
# LaTeX 习惯写 `file.sty',需避免 markdown 解析
*(f" - ```{e}```" for e in errors),
]
)
)
return running_error

duration = perf_counter() - start
log(f"✅{self.icon} 可正常编译 {self.name}:⌛ {duration:.1f} 秒。")
Expand Down