IMMORTALJAY commited on
Commit
379d005
·
verified ·
1 Parent(s): 317ca5c

Create utils/code_explainer.py

Browse files
Files changed (1) hide show
  1. utils/code_explainer.py +23 -0
utils/code_explainer.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def explain_code(code):
2
+ """Provide a simple explanation of the generated code"""
3
+ explanation = []
4
+
5
+ if "<!DOCTYPE html>" in code:
6
+ explanation.append("This is a complete HTML5 document.")
7
+
8
+ if "<style>" in code or "style=" in code:
9
+ explanation.append("The page includes CSS styling.")
10
+
11
+ if "<script>" in code or "onclick=" in code:
12
+ explanation.append("JavaScript functionality is included.")
13
+
14
+ if "nav" in code or "navbar" in code:
15
+ explanation.append("Contains a navigation bar.")
16
+
17
+ if "dark mode" in code.lower():
18
+ explanation.append("Includes dark/light mode toggle functionality.")
19
+
20
+ if not explanation:
21
+ return "The generated code appears to be a basic HTML page."
22
+
23
+ return "The website includes:\n- " + "\n- ".join(explanation)