From e09a770ff294c254d0367d8040fcb43365865578 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 26 Nov 2021 21:35:49 +0100 Subject: initial commit --- .gitignore | 2 ++ README.md | 0 build.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ clone.sh | 1 + script.js | 0 style.css | 7 ++++++ 6 files changed, 85 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 build.py create mode 100755 clone.sh create mode 100644 script.js create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..02987d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +caniuse.rs/ +target/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/build.py b/build.py new file mode 100755 index 0000000..2fd4c26 --- /dev/null +++ b/build.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +import glob +import json +import os +import shutil + +import toml + + +def get_features(dirname): + features = {} + for feature in sorted(os.listdir('caniuse.rs/data/' + dirname)): + with open('caniuse.rs/data/' + dirname + '/' + feature) as f: + name = feature.split('.')[0] + features[name] = toml.load(f) + return features + + +with open('caniuse.rs/data/versions.toml') as f: + versions = toml.load(f) + +for version, data in versions.items(): + try: + data['features'] = get_features(version) + except FileNotFoundError: + pass + +unstable_features = get_features('unstable') + + +os.makedirs('target', exist_ok=True) +shutil.copy('style.css', 'target') + +with open('target/data.json', 'w') as f: + json.dump(dict(unstable=unstable_features, versions=versions), f) + + +def write_features(f, features): + f.write('') + + +with open('target/index.html', 'w') as f: + f.write('') + f.write('') + f.write('Rust features') + f.write('

Rust features

') + f.write('') + + # TODO: sort by T-lang and T-lib + f.write('

Unstable features

') + write_features(f, unstable_features) + + for version, data in reversed(list(versions.items())): + f.write('

{}

'.format(version)) + if 'features' in data: + write_features(f, data['features']) + +# TODO: generate HTML diff --git a/clone.sh b/clone.sh new file mode 100755 index 0000000..d3a214a --- /dev/null +++ b/clone.sh @@ -0,0 +1 @@ +git clone https://github.com/jplatte/caniuse.rs diff --git a/script.js b/script.js new file mode 100644 index 0000000..e69de29 diff --git a/style.css b/style.css new file mode 100644 index 0000000..4d10490 --- /dev/null +++ b/style.css @@ -0,0 +1,7 @@ +body { + font-family: sans; +} + +ul { + columns: 300px; +} -- cgit v1.2.3