|
|
| HERE = pathlib.Path(__file__).resolve().parent |
|
| ROOT = HERE.parent.parent |
|
str | INCLUDE = ROOT / "include" / "units" |
|
str | UNITS_H = ROOT / "include" / "units.h" |
|
str | README = ROOT / "README.md" |
|
str | SUPPORTED_MD = HERE / "supported-units.md" |
|
dict | SKIP = {"namePlural", "namespaceName", "abbreviation", "nameSingular"} |
| | UNIT_ADD |
|
| WITH_METRIC = re.compile(r'\bUNIT_ADD_WITH_METRIC_PREFIXES\s*\(\s*(\w+)\s*,\s*(\w+)') |
|
| CONSTANT = re.compile(r'\b([A-Za-z_]\w*)\s*\(\s*([0-9.eE+\-]+)\s*\)\s*;\s*///<\s*(.+?)\s*$') |
Generate the reference tables (supported units, physical constants) from the headers, and keep the
copies embedded in README.md in sync so they can never drift from the code.
Everything is derived from include/units/*.h and include/units.h, so re-run this whenever a unit or
constant is added, removed, or renamed:
python3 docs/reference/gen_reference.py # rewrite files + inject README blocks
python3 docs/reference/gen_reference.py --check # exit 1 if anything is out of date (for CI)
It (1) rewrites docs/reference/supported-units.md, (2) injects the supported-units and constants tables
into README.md between the marker comments:
<!-- BEGIN generated: supported-units --> ... <!-- END generated: supported-units -->
<!-- BEGIN generated: constants --> ... <!-- END generated: constants -->