feat: fill test coverage gaps + fix \sdcol i18n labels

- examples/subst-chain.tex: substitution walkthrough with \sdbox/\sdsubst/\sdstep
- examples/antipatterns.tex: four compile-clean-but-teach-false figures
- tests/invalid/step-outside-row.tex, empty-row.tex, undeclared-role.tex,
  two-contrast-pkg.tex: negative fixtures for package-level warnings
- test.sh: add tests/invalid/ loop
- build.sh: allow superderive-build: allow directive to suppress
  intentional warnings in antipatterns galleries
- superderive.sty: \sdcol respects [en] option for illegal/legal labels
- references/api.md: complete rewrite, all ~12 macros documented
This commit is contained in:
dela
2026-08-22 10:13:36 +08:00
parent f2ccd6fb08
commit 5b24eba3c8
9 changed files with 206 additions and 7 deletions
+46
View File
@@ -0,0 +1,46 @@
% Anti-patterns -- figures that compile cleanly and still teach something false.
% ../scripts/build.sh antipatterns.tex
% superderive-lint: allow-multiple-contrast
% superderive-build: allow
\documentclass[border=10pt]{standalone}
\usepackage[cjk]{superderive}
\begin{document}
\begin{tikzpicture}
\sdstage{AP}{四张反例}
\sdrow{R1}
% AP1: \sdsubst 只填了 from,to 也是同一个 -- 改写没有产生任何变化
\sdsubst[role=rewrite]{ap1}{x+y}{x+y}
\sdreason{ap1}{subst 的 from 和 to 相同,改写为空}
\sdrowend
\sdrow{R2}
% AP2: \sdcancel 划线后旁边又写了一遍同样的东西 -- 读者不知道划掉的是哪一部分
\sdcancel[role=cancel]{ap2a}{x+y}
\sdbox[role=keep]{ap2b}{x+y}
\sdreason{ap2a}{cancel 后面紧跟同一式子,等于没有 cancel}
\sdrowend
\sdrow{R3}
% AP3: 同一行里塞了五组 role,hue budget 超了
\sdbox[role=keep]{ap3a}{a}
\sdbox[role=rewrite]{ap3b}{b}
\sdbox[role=cancel]{ap3c}{c}
\sdbox[role=intro]{ap3d}{d}
\sdbox[role=neutral]{ap3e}{e}
\sdrowend
\sdrow{R4}
% AP4: 两个 contrast pair,第二个是多余的
\sdcol{ap4a}{x+y}{x+y}
\sdcol{ap4b}{a+b}{a+b}
\sdrowend
\sdbbox{all}
\sdtopformula{F}{反例见 \texttt{references/antipatterns.md}}
\sdmeaningbox{mb}{140mm}{all}
{subst from=to;cancel 后重复;row 内五色;两个 sdcol}
{每一行都符合语法,但每一行都在说谎}
{参考 antipatterns.md 的对应规则}
\end{tikzpicture}
\end{document}