Make the properties list JSON and add some more info.

This commit is contained in:
Simon Sapin 2016-01-15 16:18:58 +01:00
parent 9d29c3d2f5
commit 2222f345c8
2 changed files with 18 additions and 7 deletions

20
components/style/list_properties.py Executable file → Normal file
View file

@ -1,14 +1,24 @@
#!/bin/env python2.7 #!/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 os.path
import sys import sys
import json
style = os.path.dirname(__file__) style = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(style, "Mako-0.9.1.zip")) sys.path.insert(0, os.path.join(style, "Mako-0.9.1.zip"))
from mako.template import Template from mako.template import Template
template = Template(filename=os.path.join(style, "properties.mako.rs"), input_encoding='utf8') template = Template(filename=os.path.join(style, "properties.mako.rs"), input_encoding='utf8')
template.render() template.render()
properties = template.module.LONGHANDS + template.module.SHORTHANDS properties = dict(
for name in sorted(p.name for p in properties): (p.name, {
print(name) "flag": p.experimental,
"shorthand": hasattr(p, "sub_properties")
})
for p in template.module.LONGHANDS + template.module.SHORTHANDS
)
print(json.dumps(properties, indent=4))

View file

@ -15,6 +15,7 @@ import sys
import os import os
import os.path as path import os.path as path
import subprocess import subprocess
import json
from collections import OrderedDict from collections import OrderedDict
from time import time from time import time
@ -158,10 +159,10 @@ class MachCommands(CommandBase):
@CommandArgument('test_name', nargs=argparse.REMAINDER, @CommandArgument('test_name', nargs=argparse.REMAINDER,
help="Only run tests that match this pattern or file path") help="Only run tests that match this pattern or file path")
def test_unit(self, test_name=None, package=None): def test_unit(self, test_name=None, package=None):
properties = subprocess.check_output([ properties = json.loads(subprocess.check_output([
sys.executable, sys.executable,
path.join(self.context.topdir, "components", "style", "list_properties.py") path.join(self.context.topdir, "components", "style", "list_properties.py")
]).splitlines() ]))
assert len(properties) >= 100 assert len(properties) >= 100
assert "margin-top" in properties assert "margin-top" in properties
assert "margin" in properties assert "margin" in properties