Commit 71990f83 authored by m417z's avatar m417z
Browse files

Update generate.py

parent 1c0c84f1
......@@ -14,10 +14,40 @@ for chunk in re.split(r'\n\s*//\s*(?=\w)', pykd_init):
first = False
else:
title, _, rest = chunk.partition('\n')
functions = re.findall(r'python::def\s*\(\s*"(.*?)",', rest)
functions = re.findall(r'python::def\s*\(\s*"(.*?)",([\s\S]*?)\);', rest)
assert(len(functions) == chunk.count('python::def'))
if len(functions) > 0:
print(f'## {title}')
func_unique = list(dict.fromkeys(functions))
print('\n'.join([f'* [{f}](https://githomelab.ru/pykd/pykd/-/wikis/API%20Reference#{f})' for f in func_unique]))
for func in functions:
name = func[0]
args = ''
description = func[1]
if re.match(r'python::raw_function\(.*\)$', description.strip()):
description = ''
description = description.replace('[python::return_value_policy<python::manage_new_object>()]', '')
description = description.replace('python::return_value_policy<python::manage_new_object>(),', '')
description = re.sub(r'^.*?,', '', description)
description = re.sub(r'\s+', ' ', description.strip())
match = re.match(r'\w+_\(\s*(?:boost::)?python::args\((.*?)\),(.*?)\)$', description)
if match:
args = match[1].replace('"', '').strip()
description = match[2].strip()
match = re.match(r'"([^"]+)"\s*\\?\s*"([^"]+)"$', description)
if match:
description = match[1].strip() + '\\n' + match[2].strip()
match = re.match(r'"([^"]+)"$', description)
if match:
description = match[1].strip()
description = re.sub(r'(\\n)+', '\n ', description)
args_suffix = f' ({args})' if args else ''
print(f'* [{name}](https://githomelab.ru/pykd/pykd/-/wikis/API%20Reference#{name}){args_suffix} ')
if description:
print(f' {description} ')
print()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment