feat(闸): 文件头闸增补 R0 载体锁死——头注非空时首行必须 ## 文档注释开头

清偿批落地后按 §1.4.1 收尾条款生效;盲测=旧式 # 头注命中/## 与无头注放行
This commit is contained in:
DKChan committed 2026-10-16 23:28:09 +08:00
1 parent 9a72394652
commit cc575b2ce3
1 file changed
+5 -2
+5 -2
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""audit_file_headers.py — 文件头机器闸(code-conventions §1.4.1 第二轮立规 2026-10-15)。
"""audit_file_headers.py — 文件头机器闸(code-conventions §1.4.1)。
文件头 = .gd 文件顶部连续注释区:连续的空行或 # 注释行,首个非注释代码行止。
本脚本只实现机械可判子集(白名单五类的人判面见规范正文):
本脚本只实现机械可判子集(两类白名单的人判面见规范正文):
R0 载体:头注非空时首行必须以 `##` 文档注释开头(清偿批落地起生效);
R1 行数上限:头注注释行(非空)> 8 行;
R2 日期:头注出现日期模式(2026-09-12 / 2026年9月 一类)——日期只属于 git log 与迭代报告;
R3 变更叙事词:「迭代N / 本迭代」、批次叙事复合词(本批/拆件批/改造批……)、「迁移到/改名为」
@@ -49,6 +50,8 @@ def audit_path(path):
hits = []
text = path.read_text(encoding="utf-8", errors="replace")
rows = header_lines(text)
if rows and not rows[0][1].lstrip().startswith("##"):
hits.append((rows[0][0], "R0 头注必须以 ## 文档注释开头"))
if len(rows) > MAX_HEADER_LINES:
hits.append((rows[0][0], "R1 头注 %d 行 > 上限 %d 行(区间 %d-%d 行)"
% (len(rows), MAX_HEADER_LINES, rows[0][0], rows[-1][0])))