From 38a13b3488a02243028a2cf4981fd40955c96f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20R=C3=A4s=C3=A4nen?= Date: Tue, 29 Mar 2016 13:05:08 +0501 Subject: [PATCH] servo: Merge #10208 - Generate html and json of supported css properties (from jrasanen:jr/issue10196); r=SimonSapin Fixes #10196. Outputs html and json of supported css properties to `target/doc/` directory when deploying github-pages. Source-Repo: https://github.com/servo/servo Source-Revision: df73a18a61e57f62e2e17541d45dcd3818b35b7c --- servo/components/style/list_properties.py | 19 +++++++++- servo/components/style/properties.html.mako | 40 +++++++++++++++++++++ servo/etc/ci/upload_docs.sh | 2 ++ servo/python/servo/testing_commands.py | 11 ++++-- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 servo/components/style/properties.html.mako diff --git a/servo/components/style/list_properties.py b/servo/components/style/list_properties.py index 63bbe2475118..34043be888b8 100644 --- a/servo/components/style/list_properties.py +++ b/servo/components/style/list_properties.py @@ -21,4 +21,21 @@ properties = dict( }) for p in template.module.LONGHANDS + template.module.SHORTHANDS ) -print(json.dumps(properties, indent=4)) + +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)) diff --git a/servo/components/style/properties.html.mako b/servo/components/style/properties.html.mako new file mode 100644 index 000000000000..d06524d3e13b --- /dev/null +++ b/servo/components/style/properties.html.mako @@ -0,0 +1,40 @@ + + + + + + + + + Supported CSS properties - servo - Rust + + + + + +
+

CSS properties currently supported in Servo

+
+ + + + + + + % for prop in properties: + + + + + + % endfor +
PropertyFlagShorthand
${prop}${properties[prop]['flag']}${properties[prop]['shorthand']}
+
+
+ + diff --git a/servo/etc/ci/upload_docs.sh b/servo/etc/ci/upload_docs.sh index 240b20d77628..2aea0fcea009 100755 --- a/servo/etc/ci/upload_docs.sh +++ b/servo/etc/ci/upload_docs.sh @@ -12,5 +12,7 @@ cd "$(dirname $0)/../.." # etc/doc.servo.org/index.html overwrites $(mach rust-root)/doc/index.html cp etc/doc.servo.org/* target/doc/ +python components/style/list_properties.py + ghp-import -n target/doc git push -qf https://${TOKEN}@github.com/servo/doc.servo.org.git gh-pages diff --git a/servo/python/servo/testing_commands.py b/servo/python/servo/testing_commands.py index b99dd147b9ad..acfce6157cfa 100644 --- a/servo/python/servo/testing_commands.py +++ b/servo/python/servo/testing_commands.py @@ -163,10 +163,17 @@ class MachCommands(CommandBase): @CommandArgument('test_name', nargs=argparse.REMAINDER, help="Only run tests that match this pattern or file path") def test_unit(self, test_name=None, package=None): - properties = json.loads(subprocess.check_output([ + subprocess.check_output([ sys.executable, path.join(self.context.topdir, "components", "style", "list_properties.py") - ])) + ]) + + this_file = os.path.dirname(__file__) + servo_doc_path = os.path.abspath(os.path.join(this_file, '../', '../', 'target', 'doc', 'servo')) + + with open(os.path.join(servo_doc_path, 'css-properties.json'), 'r') as property_file: + properties = json.loads(property_file.read()) + assert len(properties) >= 100 assert "margin-top" in properties assert "margin" in properties