summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-26 21:35:49 +0100
committerMartin Fischer <martin@push-f.com>2021-11-27 09:00:55 +0100
commite09a770ff294c254d0367d8040fcb43365865578 (patch)
treed366f2b0b74fd62522c6d9866c41e0f97f4c6060
initial commit
-rw-r--r--.gitignore2
-rw-r--r--README.md0
-rwxr-xr-xbuild.py75
-rwxr-xr-xclone.sh1
-rw-r--r--script.js0
-rw-r--r--style.css7
6 files changed, 85 insertions, 0 deletions
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
--- /dev/null
+++ b/README.md
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('<ul>')
+ for feat, data in features.items():
+ f.write('<li><a')
+ url = None
+ # print(data)
+ if 'tracking_issue_id' in data:
+ url = 'https://github.com/rust-lang/rust/issues/{}'.format(
+ data['tracking_issue_id']
+ )
+ elif 'impl_pr_id' in data:
+ url = 'https://github.com/rust-lang/rust/pull/{}'.format(data['impl_pr_id'])
+ if url:
+ f.write(f' href="{url}"')
+
+ f.write('>')
+ f.write(feat)
+ f.write('</a></li>')
+ f.write('</ul>')
+
+
+with open('target/index.html', 'w') as f:
+ f.write('<!doctype html>')
+ f.write('<meta charset=utf-8>')
+ f.write('<title>Rust features</title>')
+ f.write('<h1>Rust features</h1>')
+ f.write('<link rel="stylesheet" href="style.css" />')
+
+ # TODO: sort by T-lang and T-lib
+ f.write('<h2>Unstable features</h2>')
+ write_features(f, unstable_features)
+
+ for version, data in reversed(list(versions.items())):
+ f.write('<h2>{}</h2>'.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
--- /dev/null
+++ b/script.js
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;
+}