#!/usr/bin/env python3 """The reading order of the decision records: its topics are written, its list is generated. A number identifies a record and never changes, so the folder listing is creation order rather than reading order. The reading order is the six topics `02-DECISIONS/README.md` writes down, in order, and each record's own `topic:`. The list of records under each topic is generated from that frontmatter when somebody reads it, and never stored (ADR 0248, hq issue 297): a stored list was a line every decision pull request added to one file, so any two open at once conflicted. python3 00-META/checks/index.py check python3 00-META/checks/index.py --print print the list, by topic, in reading order It fails when the README's reading order is missing, when a record's topic is not one of its topics, and when the README stores a list of records again — the index markers, or a line of the generated list. The last one is what keeps the conflict from coming back. """ import glob import io import os import re import sys README = "02-DECISIONS/README.md" # A topic in the README's reading order, e.g. # 1. **What the mesh is** — `topic: the mesh`. What it is for, ... # The records module's `records_decisions` reads the same line, so the form is a contract. TOPIC_LINE = re.compile(r"^\d+\.\s+\*\*(?P