forked from intel/device-modeling-language
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathporting_to_md.py
31 lines (24 loc) · 872 Bytes
/
porting_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
# © 2021 Intel Corporation
# SPDX-License-Identifier: MPL-2.0
import sys
[path_to_dml, outfile] = sys.argv[1:]
sys.path.append(path_to_dml)
from dml import messages
from dml.messages import PortingMessage
portings = []
for n in dir(messages):
o = getattr(messages, n)
if (isinstance(o, type) and issubclass(o, PortingMessage)
and o is not PortingMessage):
portings.append(o)
portings.sort(key=lambda x: x.__name__)
with open(outfile, 'w') as f:
f.write("# Language differences handled by the port-dml script\n\n")
f.write("<dl>\n")
for m in portings:
assert m.__doc__
f.write(f" <dt>{m.__name__}</dt>\n")
doc = '\n'.join(line[4:] if line.startswith(' ') else line
for line in m.__doc__.strip().splitlines())
f.write(f" <dd>\n\n{doc}\n</dd>\n")
f.write("</dl>\n")