-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui_lint.py
More file actions
58 lines (45 loc) · 2.05 KB
/
ui_lint.py
File metadata and controls
58 lines (45 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import re
def audit_ui_linkage(file_path):
print(f"🔍 Auditing UI Linkage: {os.path.basename(file_path)}")
with open(file_path, 'r') as f:
content = f.read()
# Find all interactive-looking elements (buttons, drop-rows, menu-items)
# We look for onclick or uiCommand calls
interactive_elements = re.findall(r'<(button|div|span)[^>]+class=["\'][^"\']*(btn|item|row)[^"\']*["\'][^>]*>', content)
total_found = len(interactive_elements)
linked_count = 0
failures = []
# Regex for onclick or any linked action
# We specifically look for onclick="...uiCommand..." or unique functions
tags = re.finditer(r'<(button|div|span)([^>]+)>', content)
for match in tags:
tag_type = match.group(1)
attrs = match.group(2)
# Filter for only UI elements we care about
if 'btn' in attrs or 'item' in attrs or 'row' in attrs or 'onclick' in attrs:
if 'onclick' in attrs:
linked_count += 1
else:
# Potential failure
label_match = re.search(r'>(.*?)<', content[match.end():match.end()+100])
label = label_match.group(1).strip() if label_match else "Unknown Label"
failures.append(f"MISSING LINK: <{tag_type}> {label}")
success_rate = (linked_count / total_found * 100) if total_found > 0 else 100
print(f"✅ Audit Complete: {linked_count}/{total_found} elements linked ({success_rate:.1f}%)")
if failures:
print("❌ FAILURES DETECTED:")
for f in failures:
print(f" - {f}")
return success_rate, failures
if __name__ == "__main__":
controller_path = "shader_overlay/engine_controller.html"
editor_path = "shader_overlay/editor_ui.html"
c_score, c_fails = audit_ui_linkage(controller_path)
e_score, e_fails = audit_ui_linkage(editor_path)
total_score = (c_score + e_score) / 2
print(f"\n🏆 FINAL UI SCORE: {total_score:.1f}%")
if total_score < 100:
exit(1)
else:
exit(0)