Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Add **Status:** Active Documentation to docs that have **Last Updated:** but no **Status:** in first 20 lines."""
|
|
import re
|
|
import sys
|
|
|
|
STATUS_LINE = "**Status:** Active Documentation\n"
|
|
|
|
|
|
def add_status(path: str) -> bool:
|
|
try:
|
|
with open(path, "r", encoding="utf-8", errors="replace") as f:
|
|
lines = f.readlines()
|
|
except Exception as e:
|
|
print(f"Read error {path}: {e}", file=sys.stderr)
|
|
return False
|
|
if not lines:
|
|
return False
|
|
first_20 = "".join(lines[:20])
|
|
if "**Status:**" in first_20 or "Status:" in first_20:
|
|
return False
|
|
if "**Last Updated:**" not in first_20:
|
|
return False
|
|
# Find the line index of **Last Updated:** and insert Status after it (or after Document Version if present)
|
|
insert_after = None
|
|
for i, line in enumerate(lines[:20]):
|
|
if "**Last Updated:**" in line:
|
|
insert_after = i
|
|
break
|
|
if insert_after is None:
|
|
return False
|
|
# If next line is **Document Version:**, insert after that
|
|
if insert_after + 1 < len(lines) and "**Document Version:**" in lines[insert_after + 1]:
|
|
insert_after += 1
|
|
# Insert Status line after insert_after
|
|
new_lines = lines[: insert_after + 1] + [STATUS_LINE] + lines[insert_after + 1 :]
|
|
try:
|
|
with open(path, "w", encoding="utf-8", newline="\n") as f:
|
|
f.writelines(new_lines)
|
|
except Exception as e:
|
|
print(f"Write error {path}: {e}", file=sys.stderr)
|
|
return False
|
|
return True
|
|
|
|
|
|
def main():
|
|
paths = [p.strip() for p in sys.stdin if p.strip()]
|
|
count = 0
|
|
for path in paths:
|
|
if add_status(path):
|
|
count += 1
|
|
print(path)
|
|
print(f"Added Status to {count} files.", file=sys.stderr)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|