"""TEMPLATE — Technical Note, Simplified Chinese edition (技术说明 · 中文版). Copy next to the English build.py in /source/. See MPM_Document_Standard.md §12. Rules: * Same number, slug, revision and figures as build.py; the engine adds _ZH to the file name and refuses to build until the English PDF at this revision is in the project folder. Build English first. * Translate every string here, in the same order as build.py, so the two can be compared side by side. * Figure text goes through i18n.Translator: this document's TERMS first, then _STANDARDS/glossary_zh.md. tr.check() fails the build on any English left in a figure. * Numbers come from figs.py exactly as in English. Metric first, imperial in [ ]. * The masthead carries "英文版为准" (English governs) automatically. """ import sys, pathlib HERE = pathlib.Path(__file__).resolve().parent sys.path.insert(0, str(next(p / "_STANDARDS" for p in HERE.parents if (p / "_STANDARDS").is_dir()))) sys.path.insert(0, str(HERE)) from mpmdoc import Doc, KeyRow, up, dn, i18n from figs import FIGS, MEASURED, LIMIT MARGIN = LIMIT - MEASURED TERMS = { # this document's figure phrases (single terms: glossary) f"LIMIT · {LIMIT:.1f} W": f"限值 · {LIMIT:.1f} W", } tr = i18n.Translator(TERMS) F = {k: tr.svg(f()) for k, f in FIGS.items()} tr.check() doc = Doc( number="TN-MPM-SUBJ-01", rev="0.1", date="2026-11-05", lang="zh", customer="客户名称", subject="主题", title="以问题为标题:被核查的对象", lede="两到三句话:现状,以及本说明要解决的问题。只读这一段的人也应知道本说明的目的。", meta=[("地点", "位置 / 对象"), ("要求", "判定标准 · 例如 ≤ 60 W")], slug="Customer_Short-Title", # identical to the English slug history=[("0.1", "2026-11-05", "初稿。")], ) doc.add( doc.kpis([ ("实测", f"{MEASURED:.1f} W", "测量方法"), ("限值", f"{LIMIT:.1f} W", "限值来源", "strong"), ("余量", f"{MARGIN:+.1f} W", "限值 − 实测", "ok" if MARGIN >= 0 else "bad"), ]), doc.result([ f"一句话结论,关键数值加粗 ({MEASURED:.1f} W)。", "结论成立的前提条件,以及条件不满足时的变化。", ]), doc.section("对比"), doc.table( [("项目", ""), ("数值", "m r"), ("变化", "d r"), ("备注", "")], [ ["行", "1.0", up("+1.0"), "数据来源"], KeyRow(["关键行", "2.0", dn("−0.5"), "最多突出一行"]), ], caption="表格内容、单位及基准。", ref="cmp"), doc.section("计算"), doc.calc([ "# 每步一行注释,说明原因", ("余量", "限值 − 实测 = {:.1f} − {:.1f}".format(LIMIT, MEASURED), f"{MARGIN:+.1f} W", "PASS" if MARGIN >= 0 else "FAIL"), ]), doc.section("图示"), doc.figure(F["bars"], "图注说明应关注的内容。正文中引用为 [[fig:bars]]。", ref="bars"), doc.assumptions( ["结论所依据的每项假设,每条一项。"], ["所有待确认事项,以动作表述(确认……、补充……)。"], ), ) doc.build()