forked from Marus/cortex-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options-doc.py
executable file
·82 lines (66 loc) · 3.05 KB
/
options-doc.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
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
76
77
78
79
80
81
82
#!/usr/bin/env python3
import pprint
import json
import re
pp = pprint.PrettyPrinter()
expected_diff_properties = ['overrideAttachCommands', 'overrideLaunchCommands',
'postAttachCommands', 'postLaunchCommands',
'preAttachCommands', 'preLaunchCommands',
'runToEntryPoint', 'runToMain']
def get_properties(pkg, type):
attributes = pkg['contributes']['debuggers'][0]['configurationAttributes'][type]
return dict([(p, attributes['properties'][p].get('description', '(unknown)'))
for p in attributes['properties']])
with open('package.json') as f:
package = json.load(f)
attach_properties = get_properties(package, 'attach')
launch_properties = get_properties(package, 'launch')
extra_properties = list(set(list(attach_properties.keys() -
launch_properties.keys()) + list(launch_properties.keys() - attach_properties.keys())) - set(expected_diff_properties))
extra_properties.sort()
if len(extra_properties) > 0:
print("WARNING: launch_properties and attach_properties DIFFER UNEXPECTEDLY:")
print(extra_properties)
# pp.pprint(attach_properties)
with open('src/common.ts') as f:
common_ts = f.read()
config_args = re.search(
'^export interface ConfigurationArguments extends DebugProtocol.LaunchRequestArguments {(.*?)^}$', common_ts, re.M + re.S).groups()[0]
categories = {}
category_name = ''
category_list = []
for line in config_args.splitlines():
line = line.strip()
if len(line) == 0:
continue
if line.startswith('// '):
categories[category_name] = category_list
category_name = line[3:]
category_list = []
else:
category_list.append(line.split(':')[0])
categories[category_name] = category_list
# pp.pprint(categories)
MISSING_ATTRIBUTES = ['extensionPath',
'flattenAnonymous', 'registerUseNaturalFormat', 'variableUseNaturalFormat', 'toolchainPath']
all_properties = {**attach_properties, **launch_properties}
with open('debug_attributes.md', 'w') as f:
f.write('| Attribute | Applies To | Description |\n')
f.write('| --------- | ---------- | ----------- |\n')
for category in sorted(categories.keys()):
if len(category) == 0:
category_name = 'Common'
else:
category_name = category
for attribute in sorted(categories[category]):
if attribute in MISSING_ATTRIBUTES:
continue
if attribute in all_properties.keys():
if attribute in attach_properties.keys() and attribute in launch_properties.keys():
if attach_properties[attribute] != launch_properties[attribute]:
print("WARNING: configuration property {} DIFFER UNEXPECTEDLY between attach and launch".format(attribute))
f.write('| {} | {} | {}\n'.format(
attribute, category_name, all_properties[attribute]))
else:
f.write('| {} | {} | ????\n'.format(
attribute, category_name))