diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-27 08:37:19 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-27 12:38:56 +0100 |
commit | bf351b8247da142213a5df3b0694a2c09584bceb (patch) | |
tree | 062b4e1f903715674b857b046f6a552eb2f67326 | |
parent | e09a770ff294c254d0367d8040fcb43365865578 (diff) |
html: merge features
-rwxr-xr-x | build.py | 43 |
1 files changed, 38 insertions, 5 deletions
@@ -35,18 +35,51 @@ 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') +def write_features(f, feature_data): + features = {} + for feat, data in feature_data.items(): + key = data['flag'] if 'flag' in data else feat + # caniuse.rs sometimes has several .toml files for one feature flag e.g. + # For the const_io feature flag it has 6 .toml files, all with the same + # tracking_issue_id and the following titles: + # + # * `io::Cursor::get_ref` as `const fn` + # * `io::Cursor::new` as `const fn` + # * `io::Cursor::position` as `const fn` + # * `io::empty` as `const fn` + # * `io::repeat` as `const fn` + # * `io::sink` as `const fn` + # + # That makes sense for a search-centric application. Not so much for a + # static-site generator since showing the same link 6 times is confusing. + 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']) + data['url'] = url + data['filename'] = feat + + if key in features and features[key]['url'] != url: + print( + 'different urls for feature {}:\n* {}: {}\n* {}: {}'.format( + key, + data['filename'], + data['url'], + features[key]['filename'], + features[key]['url'], + ) + ) + + features[key] = data + + f.write('<ul>') + for feat, data in features.items(): + f.write('<li><a') + url = data['url'] if url: f.write(f' href="{url}"') |