Files
Jason StedwellandClaude Opus 5.5 5b52636003 MPM Documentation Kit v1.3 (CW-034)
MPM Document Standard 1.3, mpmdoc build engine, templates for TN, INS, SOP,
BOM, SVY, TAP, DWG, TSB, PRO, SOW and WO (Chinese editions for TN and DWG),
glossary, MPM fonts and logos, and the mpm-technical-documents plugin 1.3.0.
Worked examples ship in the kit zip on Drive only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWatTMmqmGatgHjDZvWs5b
2026-11-09 11:51:56 -06:00

77 lines
3.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""TEMPLATE — Technical Note, Simplified Chinese edition (技术说明 · 中文版).
Copy next to the English build.py in <PROJECT>/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"一句话结论,关键数值加粗 <b>({MEASURED:.1f} W)</b>。",
"结论成立的前提条件,以及条件不满足时的变化。",
]),
doc.section("对比"),
doc.table(
[("项目", ""), ("数值", "m r"), ("变化", "d r"), ("备注", "")],
[
["行", "1.0", up("+1.0"), "数据来源"],
KeyRow(["<b>关键行</b>", "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()