diff options
Diffstat (limited to 'scripts/newos4-maintain.py')
| -rw-r--r-- | scripts/newos4-maintain.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/newos4-maintain.py b/scripts/newos4-maintain.py index 10ac62b..dd6c898 100644 --- a/scripts/newos4-maintain.py +++ b/scripts/newos4-maintain.py @@ -100,6 +100,34 @@ def check_course(): r = run([sys.executable, 'scripts/course-validate.py'], cwd=ROOT) add('PASS' if r.returncode == 0 else 'FAIL', 'course ' + ('valid' if r.returncode == 0 else 'INVALID: ' + r.stdout[-160:])) +def check_help_coverage(): + """Every command the code registers must appear in help.html (2026-10-22). + + help.html had a 74-command backlog because nothing compared the two. This + check makes the gap visible on every maintenance run. + """ + cmds, term = set(), open(os.path.join(ROOT, 'modules/core/terminal.js'), encoding='utf-8').read() + for m in re.finditer(r'this\._baseWhitelist = \[(.*?)\];', term, re.S): + cmds.update(re.findall(r"'([^']+)'", m.group(1))) + for m in re.finditer(r'const internals = \[(.*?)\];', term, re.S): + cmds.update(re.findall(r"'([^']+)'", m.group(1))) + cmds.update(re.findall(r"cmd === ['\"]([a-z0-9_-]+)['\"]", term)) + for p in glob.glob(os.path.join(ROOT, 'modules/**/*.js'), recursive=True): + if 'bundle' in p or '/test/' in p or '.bkp' in p: + continue + src = open(p, encoding='utf-8', errors='ignore').read() + cmds.update(re.findall(r"commands\[['\"]([a-z0-9_-]+)['\"]\]\s*=", src)) + doc = open(os.path.join(ROOT, 'help.html'), encoding='utf-8').read() + documented = set() + for tok in re.findall(r'<code>([^<]+)</code>', doc): + first = tok.replace('<', ' ').replace('>', ' ').split() + if first and re.fullmatch(r'[a-z][a-z0-9_-]{0,40}', first[0].lstrip('./')): + documented.add(first[0].lstrip('./')) + missing = sorted(cmds - documented) + add('PASS' if not missing else 'WARN', + f'help coverage {len(cmds) - len(missing)}/{len(cmds)} commands' + + ('' if not missing else f' — undocumented: {", ".join(missing[:8])}')) + def check_links(): if not DEEP: return broken = [] @@ -115,7 +143,7 @@ def check_links(): def main(): os.chdir(ROOT) - check_versions(); check_bundles(); check_syntax(); check_perms(); check_index(); check_data(); check_live(); check_atlas(); check_course(); check_links() + check_versions(); check_bundles(); check_syntax(); check_perms(); check_index(); check_data(); check_live(); check_atlas(); check_course(); check_help_coverage(); check_links() fails = [m for l, m in issues if l == 'FAIL'] print('newOS4 maintenance — ' + datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%MZ') + (' [fix]' if FIX else '') + (' [deep]' if DEEP else '')) for l, m in issues: print(f'{l}: {m}') |