unification: SUMMARY → CANON v1 (Final counts, at-a-glance renamed, Authors—EN→RU generated for sec02/03 from dossiers, legacy blocks → Notes ###; sec04 totals row added; 0 rows lost)
This commit is contained in:
parent
a5d6b9a0d9
commit
680bf45ee1
6 changed files with 581 additions and 339 deletions
44
tools/make_authors_table.py
Normal file
44
tools/make_authors_table.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Build `## Authors — EN → RU` table for a section SUMMARY from AUTHORS-EN.md + dossiers.
|
||||
Usage: python3 tools/make_authors_table.py <section>"""
|
||||
import re, sys, os
|
||||
|
||||
def ru_name_of(dossier):
|
||||
if not os.path.exists(dossier):
|
||||
return '—'
|
||||
c = open(dossier, encoding='utf-8').read()
|
||||
# bold field forms
|
||||
for m in re.finditer(r'\*\*RU name[^:]*:\*\* (.+)', c):
|
||||
return m.group(1).strip()
|
||||
# section forms
|
||||
m = re.search(r'^(?:## |\*\*)?RU name[^:*\n]*:?\*\*?\n(.+)', c, re.M)
|
||||
if m:
|
||||
return m.group(1).strip()
|
||||
m = re.search(r'^## [^\n]*RU name[^\n]*\n+(.+)', c, re.M | re.I)
|
||||
if m:
|
||||
return m.group(1).strip()
|
||||
return '—'
|
||||
|
||||
def main():
|
||||
sec = sys.argv[1]
|
||||
idx = f'sections/{sec}/AUTHORS-EN.md'
|
||||
c = open(idx).read()
|
||||
rows = []
|
||||
for l in c.split('\n'):
|
||||
if l.startswith('|') and not re.match(r'^\|\s*item', l) and not re.match(r'^\|[-\s|]+\|', l):
|
||||
cells = [x.strip() for x in l.strip().strip('|').split('|')]
|
||||
if len(cells) >= 3:
|
||||
items, en, d = cells[0], cells[1], cells[2]
|
||||
if d.startswith('..'):
|
||||
d = os.path.normpath(os.path.join('sections', sec, d))
|
||||
else:
|
||||
d = d.lstrip('./')
|
||||
rows.append((items, en, ru_name_of(d)))
|
||||
out = ['| item(s) | EN author | RU name | verified via |',
|
||||
'|---------|-----------|---------|--------------|']
|
||||
for items, en, ru in rows:
|
||||
out.append(f'| {items} | {en} | {ru} | dossier |')
|
||||
print('\n'.join(out))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue