-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_docs.py
More file actions
94 lines (75 loc) · 3.02 KB
/
validate_docs.py
File metadata and controls
94 lines (75 loc) · 3.02 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
import os
import re
def validate_docs_page():
"""Validate that the docs page references all components correctly."""
# Read the index.html file
with open('index.html', 'r') as f:
content = f.read()
# List of expected components
expected_components = [
'accordion', 'alert', 'badge', 'card', 'carousel', 'loading-button',
'modal', 'nav-tabs', 'navbar', 'pagination', 'placeholder', 'spinner',
'theme-toggle', 'toast', 'tooltip'
]
# Check if each component has a section in the docs
missing_sections = []
for component in expected_components:
# Look for section IDs like id="accordion"
if f'id="{component}"' not in content:
missing_sections.append(component)
# Check if all component JS files are referenced
js_files = []
component_js_pattern = r'<script src="components/([^/]+)/([^"]+\.js)"'
matches = re.findall(component_js_pattern, content)
for component_dir, js_file in matches:
js_files.append(f"{component_dir}/{js_file}")
# Check if the JS files actually exist
missing_js_files = []
for js_file in js_files:
if not os.path.exists(f"components/{js_file}"):
missing_js_files.append(js_file)
print("=== Documentation Validation Report ===")
print()
if missing_sections:
print("❌ Missing component sections:")
for section in missing_sections:
print(f" - {section}")
print()
else:
print("✅ All component sections are present")
print()
print(f"📄 Found {len(js_files)} JavaScript file references:")
for js_file in sorted(js_files):
print(f" - {js_file}")
print()
if missing_js_files:
print("❌ Missing JavaScript files:")
for js_file in missing_js_files:
print(f" - {js_file}")
print()
else:
print("✅ All referenced JavaScript files exist")
print()
# Count component demos
demo_count = content.count('class="component-demo"')
print(f"🎯 Found {demo_count} component demos")
# Check for Bootstrap dependencies
bootstrap_css = 'bootstrap.min.css' in content
bootstrap_js = 'bootstrap.bundle.min.js' in content
bootstrap_icons = 'bootstrap-icons.min.css' in content
print()
print("🔍 Bootstrap dependencies:")
print(f" - Bootstrap CSS: {'✅' if bootstrap_css else '❌'}")
print(f" - Bootstrap JS: {'✅' if bootstrap_js else '❌'}")
print(f" - Bootstrap Icons: {'✅' if bootstrap_icons else '❌'}")
# Overall validation
all_good = not missing_sections and not missing_js_files and bootstrap_css and bootstrap_js and bootstrap_icons
print()
if all_good:
print("🎉 Documentation page is valid and ready for GitHub Pages!")
else:
print("⚠️ Documentation page has some issues that need attention.")
return all_good
if __name__ == "__main__":
validate_docs_page()