Commit 2a50db78 authored by m417z's avatar m417z
Browse files

Grab arguments from official docs

parent 901af5e1
This diff is collapsed.
import urllib.request
import html
import re
response = urllib.request.urlopen('https://githomelab.ru/pykd/pykd/-/raw/0.3.2/pykd/pymod.cpp')
cpp = response.read().decode().replace('\r\n', '\n')
response = urllib.request.urlopen('https://githomelab.ru/pykd/pykd/-/wikis/API%20Reference')
docs = response.read().decode().replace('\r\n', '\n')
pykd_init = re.search(r'\nvoid pykd_init\(\)\n\{\n([\s\S]*?)\n\}', cpp).group(1)
first = True
......@@ -31,9 +35,14 @@ for chunk in re.split(r'\n\s*//\s*(?=\w)', pykd_init):
description = re.sub(r'^.*?,', '', description)
description = re.sub(r'\s+', ' ', description.strip())
match = re.search(rf'<span id="LC2" class="line" lang="plaintext">(?:object )?{re.escape(name)}(\([^<]*?) :</span>', docs)
if match:
args = html.unescape(match.group(1)).strip()
match = re.match(r'\w+_\(\s*(?:boost::)?python::args\((.*?)\),(.*?)\)$', description)
if match:
args = match[1].replace('"', '').strip()
if not args:
args = '(' + match[1].replace('"', '').strip() + ')'
description = match[2].strip()
match = re.match(r'"([^"]+)"\s*\\?\s*"([^"]+)"$', description)
......@@ -46,7 +55,7 @@ for chunk in re.split(r'\n\s*//\s*(?=\w)', pykd_init):
description = re.sub(r'(\\n)+', ' \n ', description)
args_suffix = f' ({args})' if args else ''
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}')
......
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