Skip to content

Commit a1a557e

Browse files
committed
docs: a translation must carry the same tables and code blocks, and four that did not
check_docs_style.sh compares heading STRUCTURE, which catches a page that has fallen a section behind. It cannot see a table row or a code block that never made it across, and four were sitting in the tree — none introduced by this batch, and none visible to any other check: docs/zh/22 (from 05) the `[features]` section had NO BODY: the TOML example that defines the syntax and all three bullets were absent, in the section that defines the mechanism docs/zh/05 §2.11 the `identity` verdict table — ok / mismatch / missing / unverified — and the two paragraphs around it docs/zh/08 §7.4 the shared-library format table and what follows it: Mach-O's install name, and the refusal of an unservable target docs/zh/16 SEVEN target rows. The 简体中文 support matrix listed 14 targets where the English listed 21, all seven missing ones Cortex-M Rule 10 compares table rows and fenced code blocks per document pair. It was written after the first two were found by hand, and it immediately found the other two, which is the argument for it: a bilingual pair can agree on every heading and disagree about a support matrix.
1 parent 9bba95d commit a1a557e

5 files changed

Lines changed: 103 additions & 0 deletions

File tree

.github/tools/check_docs_structure.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# 7. the generated design-record index is current
1414
# 8. a new design record declares its subject and status
1515
# 9. every relative link in docs/ and examples/ resolves
16+
# 10. a translation carries the same tables and code blocks
1617
#
1718
# What it deliberately does NOT check: whether a chapter documents what is
1819
# implemented, whether an assertion's strength matches its evidence, or whether
@@ -160,6 +161,46 @@ for f in list(pathlib.Path("docs").rglob("*.md")) + list(pathlib.Path("examples"
160161
sys.exit(1 if bad else 0)
161162
PYCHECK
162163

164+
# ── 10. a translation carries the same tables and code blocks ────────────
165+
#
166+
# check_docs_style.sh compares HEADING STRUCTURE, which is what catches a page
167+
# that has fallen a section behind. It does not see a table row or a code block
168+
# that never made it across, and two of those were sitting in the tree: the
169+
# 简体中文 `[features]` section had no body at all, and 简体中文 §2.11 was
170+
# missing the `identity` verdict table. Both predate this check and both are
171+
# invisible to every other one.
172+
python3 - <<'PYPARITY' || fail=1
173+
import pathlib, sys, re
174+
bad = 0
175+
for en in sorted(pathlib.Path("docs").glob("*.md")):
176+
zh = pathlib.Path("docs/zh") / en.name
177+
if not zh.exists():
178+
continue
179+
def count(f):
180+
rows = blocks = 0
181+
infence = False
182+
for line in f.read_text(errors="ignore").split("\n"):
183+
if line.startswith("```"):
184+
if not infence:
185+
blocks += 1
186+
infence = not infence
187+
continue
188+
if infence:
189+
continue
190+
if line.startswith("|"):
191+
rows += 1
192+
return rows, blocks
193+
er, eb = count(en)
194+
zr, zb = count(zh)
195+
if er != zr:
196+
print(f"FAIL: {en.name}: {er} table rows in English, {zr} in 简体中文")
197+
bad += 1
198+
if eb != zb:
199+
print(f"FAIL: {en.name}: {eb} code blocks in English, {zb} in 简体中文")
200+
bad += 1
201+
sys.exit(1 if bad else 0)
202+
PYPARITY
203+
163204
if [[ "$fail" -eq 0 ]]; then
164205
echo "OK: docs structure checks pass"
165206
fi

docs/zh/05-mcpp-toml.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,21 @@ requirements/providers/artifacts、LinkIntent、平台搜索机制与链接后 v
10991099
`mcpp why runtime` 只是最新存储文件的纯解释器:不重新解析 manifest,也不启动图形/
11001100
硬件 probe。需要重新诊断所选 host provider 时使用 `xlings doctor`
11011101

1102+
每个 artifact 还带一个仅由路径算出的 `identity` 判定:
1103+
1104+
| `identity` | 含义 |
1105+
|---|---|
1106+
| `ok` | 声明的路径(穿过符号链接后)落在声明的那个版本里 |
1107+
| `mismatch` | 它解析到了别处 —— **该 binding 已陈旧**,后来的某次安装把它重新指向了别的地方 |
1108+
| `missing` | 声明了,但那个路径上什么都没有 |
1109+
| `unverified` | 声明时没有可供比对的版本 |
1110+
1111+
这就是 mcpp 早已施加于私有 libc 的那条规则的推广(`glibc@2.44` 解析到那一份载荷;
1112+
陈旧或缺失是错误,而绝不是「已安装版本里哪个看起来能用就用哪个」)。它不需要知道
1113+
该 artifact 做什么。`unverified` **有意**不等于 `ok`:一个解析到了却没有 artifact
1114+
在其背后的 provider 并未被核验过,因此 `mcpp why runtime` 打印
1115+
`(not declared by the environment — nothing to verify)` 而不是 `(none)`
1116+
11021117
能力名使用分层小写 `domain.sub.role`(如 `display.present`)和前缀类
11031118
`abi:<name>`(如 `abi:glibc`,参与工具链 ABI 强制)。
11041119

docs/zh/08-toolchain-internals.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,30 @@ C 世界(`CLibMode::Sysroot`)并有自己的 libc++ 链接处理;Windows 没有
464464
mcpp 把运行时 DLL 部署到产物 exe 旁,这正是该平台对 §3–§4 所做一切的原生
465465
等价物。
466466

467+
**工程自己产出的共享库**(`kind = "shared"`)确实按格式而不同,而这个差别不是
468+
flag 的拼法 —— 它是产物记录下的关于它自己的东西:
469+
470+
| 格式 | 生产方发出什么 | 消费方链接什么 |
471+
|---|---|---|
472+
| ELF | 声明了 soname 时发 `-Wl,-soname,<n>` | `-L` + `-l``-Wl,-rpath,$ORIGIN` |
473+
| Mach-O | **总是**`-Wl,-install_name,@rpath/<file>` | `-L` + `-l``-Wl,-rpath,@loader_path` |
474+
| PE / MinGW | `-Wl,--out-implib,<lib>` | **导入库**,且 `-Wl,-Bdynamic` 在前 |
475+
| PE / MSVC | 拒绝(不做自动导出;见 docs/12) | —— |
476+
477+
其中三行是新增的:在此之前,除 ELF 之外一律被拒绝,原生与交叉都是。要让它们
478+
可用而不只是被允许,有两处细节必须改。Mach-O 的 install name 默认取该库被**链接**
479+
时的路径,因此「仅在声明了 `soname` 时才发出」会让其余每个 `.dylib` 都记下一个构建
480+
目录 —— 在构建它的那台机器上没问题,换任何一台就是 `image not found`。而这个选择
481+
原先由宿主上的 `#if defined(__APPLE__)` 做出,那只在原生 macOS 构建上碰巧正确,
482+
对任何交叉链接都是错的;它现在由目标决定,正如 `target_output` 早已如此。
483+
484+
**服务不了的目标会被拒绝**,而不是悄悄按宿主构建:Linux 上的
485+
`--target x86_64-windows-msvc` 从前会解析到原生 `g++`、写进
486+
`target/x86_64-linux-gnu/` 并报告成功。词汇表的档位说的是「mcpp 支持这个目标」;
487+
`host_can_serve`(`registry.cppm`)回答的是另一个问题「这台机器能不能产出它」,
488+
`prepare.cppm` 现在会问它 —— 显式的 `[target.X] toolchain = "…"` 是作者自备
489+
交叉工具链时的出口。
490+
467491
### 7.5 一个 flag 由哪根轴决定
468492

469493
2026.8.18 那一轮改了四个 flag,每一个此前都挂在错误的轴上。而这类错误的表现

docs/zh/16-the-target-triple.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ CRT;图供给时是 `musl`。一个目标字符串,两个不同的 C 库 ——
383383
| `riscv32-none-elf` | verified | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
384384
| `aarch64-none-elf` | preview | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
385385
| `x86_64-none-elf` | preview | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
386+
| `thumbv6m-none-eabi` | verified | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
387+
| `thumbv7m-none-eabi` | verified | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
388+
| `thumbv7em-none-eabi` | preview | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
389+
| `thumbv7em-none-eabihf` | verified | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
390+
| `thumbv8m.base-none-eabi` | preview | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
391+
| `thumbv8m.main-none-eabi` | verified | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
392+
| `thumbv8m.main-none-eabihf` | preview | `llvm@22.1.8` | 载荷 | 载荷 | 载荷 | 载荷 |
386393

387394
`载荷` 这里有工具链载荷产出它 · `` 没有载荷,但依赖可以供给系统 ·
388395
`系统` 在机器上被找到,不是 mcpp 装的 · `SDK` 平台自己的 ·

docs/zh/22-features-and-capabilities.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ Feature 是一个包提供可选内容的方式:一个编译宏、一份额外
1010

1111
## `[features]` —— Feature(Cargo 风格,可加性)
1212

13+
```toml
14+
[features]
15+
default = ["base"] # 默认激活集合
16+
base = []
17+
docking = ["extra"] # 激活 docking 即隐含激活 extra(传递闭包)
18+
extra = []
19+
```
20+
21+
- 激活来源:包自己的 `default` 集合 ∪ 显式请求(根包经由
22+
`mcpp build --features a,b`;依赖经由长形式依赖 spec 的 `features = [...]`
23+
`backend = "..."` 糖)。
24+
- 每个被激活的 feature 在该包编译时得到宏 `-DMCPP_FEATURE_<NAME>`(名字大写,
25+
非字母数字变 `_`,例如 `backend-a``MCPP_FEATURE_BACKEND_A`)。
26+
- **严格校验**:目标包声明了 `[features]` 表时,请求一个未声明的 feature 产生
27+
警告,在 `--strict` 下是错误。不声明 `[features]` 的包接受任意请求(纯宏用法)。
28+
1329
### 表形式 —— 让 feature 贡献的不止是隐含 feature
1430

1531
`[features]` 的条目除了写成数组,还可写成****,从而让该 feature 在隐含 feature

0 commit comments

Comments
 (0)