aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/list_properties.py
blob: 78c6b84f2c41c52b4384bec1af4139a58ad536fd (plain) (blame)
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
#!/usr/bin/env python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os.path
import sys
import json

style = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(style, "Mako-0.9.1.zip"))
from mako.template import Template

template = Template(filename=os.path.join(style, "properties.mako.rs"), input_encoding='utf8')
template.render(PRODUCT='servo')
properties = dict(
    (p.name, {
        "flag": p.experimental,
        "shorthand": hasattr(p, "sub_properties")
    })
    for p in template.module.LONGHANDS + template.module.SHORTHANDS
)

json_dump = json.dumps(properties, indent=4)

#
# Resolve path to doc directory and write CSS properties and JSON.
#
servo_doc_path = os.path.abspath(os.path.join(style, '../', '../', 'target', 'doc', 'servo'))

# Ensure ./target/doc/servo exists
if not os.path.exists(servo_doc_path):
    os.makedirs(servo_doc_path)

with open(os.path.join(servo_doc_path, 'css-properties.json'), "w") as out_file:
    out_file.write(json_dump)

html_template = Template(filename=os.path.join(style, "properties.html.mako"), input_encoding='utf8')
with open(os.path.join(servo_doc_path, 'css-properties.html'), "w") as out_file:
    out_file.write(html_template.render(properties=properties))