refac
This commit is contained in:
1 parent
eff5c4a2d9
commit
b606e13da3
1 file changed
+15
-6
@@ -848,17 +848,26 @@ def parse_docstring(docstring):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
# Regex to match `:param name: description` format
|
# Regex to match `:param name: description` format
|
||||||
param_pattern = re.compile(r':param (\w+):\s*(.+)')
|
param_pattern = re.compile(r':param (\w+):\s*(.*)')
|
||||||
param_descriptions = {}
|
param_descriptions = {}
|
||||||
|
current_param = None
|
||||||
|
|
||||||
for line in docstring.splitlines():
|
for line in docstring.splitlines():
|
||||||
match = param_pattern.match(line.strip())
|
line = line.strip()
|
||||||
if not match:
|
match = param_pattern.match(line)
|
||||||
|
if match:
|
||||||
|
param_name, param_description = match.groups()
|
||||||
|
current_param = None if param_name.startswith('__') else param_name
|
||||||
|
if current_param:
|
||||||
|
param_descriptions[current_param] = param_description
|
||||||
continue
|
continue
|
||||||
param_name, param_description = match.groups()
|
|
||||||
if param_name.startswith('__'):
|
if line.startswith(':'):
|
||||||
|
current_param = None
|
||||||
continue
|
continue
|
||||||
param_descriptions[param_name] = param_description
|
|
||||||
|
if current_param and line:
|
||||||
|
param_descriptions[current_param] = '\n'.join(filter(None, [param_descriptions[current_param], line]))
|
||||||
|
|
||||||
return param_descriptions
|
return param_descriptions
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user