-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathprovisional_to_md.py
33 lines (30 loc) · 1.17 KB
/
provisional_to_md.py
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
# © 2024 Intel Corporation
# SPDX-License-Identifier: MPL-2.0
import sys
from pathlib import Path
[path_to_dml, header, outfile] = sys.argv[1:]
sys.path.append(path_to_dml)
from dml import provisional
from dml.env import api_versions, default_api_version
with open(outfile, 'w') as f:
f.write(Path(header).read_text())
stable = [feature for feature in provisional.features.values()
if feature.stable]
unstable = [feature for feature in provisional.features.values()
if not feature.stable]
for (heading, features) in [
('List of stable provisional features', stable),
('List of unstable provisional features', unstable)]:
if not features:
continue
f.write(f"""
## {heading}
""")
f.write("<dl>\n")
for feature in sorted(features, key=lambda f: f.tag()):
assert feature.__doc__
f.write(f" <dt><tt>{feature.tag()}</tt></dt>\n")
doc = '\n'.join(line[4:] if line.startswith(' ') else line
for line in feature.__doc__.strip().splitlines())
f.write(f" <dd>\n\n{doc}\n</dd>\n")
f.write("</dl>\n")