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
This commit is contained in:
Jason StedwellandClaude Opus 5.5 committed 2026-11-09 11:51:56 -06:00
commit 5b52636003
143 files changed
+4097

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
"""Number / unit / date formatters so every document writes values the same way.
See MPM_Document_Standard.md §5 (Units and numbers)."""
import datetime as _dt
from fractions import Fraction
def ftin(x):
"""Inches -> feet-inches to the nearest 1/16: 154 -> 12'-10", 153.5 -> 12'-9 1/2"."""
x = round(x * 16) / 16
ft = int(x // 12)
rem = x - ft * 12
whole = int(rem)
frac = Fraction(rem - whole).limit_denominator(16)
f = f" {frac.numerator}/{frac.denominator}" if frac else ""
return f"{ft}'-{whole}{f}\""
def inch(x):
"""Inches to the nearest 1/16: 7.25 -> 7 1/4"."""
x = round(x * 16) / 16
whole = int(x)
frac = Fraction(x - whole).limit_denominator(16)
if frac and whole:
return f"{whole} {frac.numerator}/{frac.denominator}\""
if frac:
return f"{frac.numerator}/{frac.denominator}\""
return f"{whole}\""
def mm_in(mm, digits=2):
"""'1448 mm (57.01 in.)' — metric primary with inch conversion."""
return f"{mm:g} mm ({mm / 25.4:.{digits}f} in.)"
def signed(s, value):
"""Prefix a true minus sign or plus: signed('13\"', -1) -> '−13\"'."""
return ("−" if value < 0 else "+" if value > 0 else "") + s
def parse_date(d):
if isinstance(d, _dt.date):
return d
return _dt.date.fromisoformat(d)
def show_date(d):
"""Display format used on every page: 'Nov 5, 2026'."""
d = parse_date(d)
return f"{d:%b} {d.day}, {d.year}"