3 |
3 |
import argparse
|
4 |
4 |
import json
|
5 |
5 |
import os
|
|
6 |
import xml.etree.ElementTree as ET
|
6 |
7 |
|
7 |
8 |
parser = argparse.ArgumentParser()
|
8 |
9 |
parser.add_argument('--overlay', dest='overlay', type=str)
|
9 |
10 |
args = parser.parse_args()
|
10 |
11 |
|
|
12 |
# get themes
|
11 |
13 |
themes = []
|
12 |
14 |
for dirname in sorted(os.listdir('static')):
|
13 |
15 |
config = os.path.join('static', dirname, 'config.json')
|
... | ... | |
28 |
30 |
theme['overlay'] = args.overlay
|
29 |
31 |
themes.append(theme)
|
30 |
32 |
|
|
33 |
# get parameters
|
|
34 |
parameters = {'primary-color': {'type': 'color'}}
|
|
35 |
if os.path.exists('help/fr/misc-scss.page'):
|
|
36 |
tree = ET.parse('help/fr/misc-scss.page')
|
|
37 |
for element in tree.findall('.//{http://projectmallard.org/1.0/}tr'):
|
|
38 |
name, description, value = element.findall('{http://projectmallard.org/1.0/}td')
|
|
39 |
name = ''.join(name.itertext()).strip('$')
|
|
40 |
description = ''.join(description.itertext()).strip('$')
|
|
41 |
value = ''.join(value.itertext()).strip('$')
|
|
42 |
parameter_type = 'text'
|
|
43 |
if (value.startswith('#') or value in ('white', 'black') or
|
|
44 |
name.endswith('color') or name.endswith('background')):
|
|
45 |
parameter_type = 'color'
|
|
46 |
if value.endswith('px') or value.endswith('rem') or name.endswith('size'):
|
|
47 |
parameter_type = 'size'
|
|
48 |
if value in ('true', 'false'):
|
|
49 |
parameter_type = 'boolean'
|
|
50 |
if name.endswith('weight'):
|
|
51 |
parameter_type = 'weight'
|
|
52 |
if name.endswith('family'):
|
|
53 |
parameter_type = 'family'
|
|
54 |
parameters[name] = {
|
|
55 |
'type': parameter_type,
|
|
56 |
'description': description,
|
|
57 |
}
|
|
58 |
|
|
59 |
|
31 |
60 |
with open('themes.json', 'w') as fd:
|
32 |
|
json.dump({'themes': themes}, fd, indent=2, sort_keys=True)
|
|
61 |
json.dump({'themes': themes, 'parameters': parameters}, fd, indent=2, sort_keys=True)
|
33 |
|
-
|