-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathcssom-generate.py
More file actions
executable file
·42 lines (33 loc) · 1.3 KB
/
cssom-generate.py
File metadata and controls
executable file
·42 lines (33 loc) · 1.3 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
# GENERATE CSSOM
from cssattrs import cssidlattributes
def property_from_attribute(attribute):
output = ""
if attribute == "cssFloat":
return "float"
for char in attribute:
if char.isupper():
output += "-"
output += char.lower()
else:
output += char
return output
def generate_propertyidl():
value = ""
for attribute in cssidlattributes.split("\n"):
value += " attribute DOMString <span title=\"dom-CSSStyleDeclaration-" + attribute + "\">" + attribute + "</span>;\n"
return value
def generate_propertytable():
value = ""
for attribute in cssidlattributes.split("\n"):
identifier = "dom-CSSStyleDeclaration-" + attribute
value += " <tr>\n <td><dfn title=\"" + identifier + "\"><code>" + attribute + "</code></dfn></td>\n <td>\"<code>" + property_from_attribute(attribute) + "</code>\"</td>\n"
return value
def generate_spec():
source = open("./cssom-source", "r").read()
source = source.replace("<!--CSSOM-DECLARATIONIDL-->\n", generate_propertyidl())
source = source.replace("<!--CSSOM-DECLARATIONTABLE-->\n", generate_propertytable())
file = open("./Overview.src.html", "w")
file.write(source)
file.close()
if __name__ == '__main__':
generate_spec()