blob: 2fd4c26780d2cbf3035c03e396fccfb705540974 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
|