mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
ifcedit discover: fix param/return doc truncation on RST inline roles
Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -236,6 +236,9 @@ def _parse_docstring_body(docstring: str) -> tuple[str, str]:
|
|||||||
return summary, long_description
|
return summary, long_description
|
||||||
|
|
||||||
|
|
||||||
|
_FIELD_MARKER = re.compile(r":(?:param|returns?|rtype|type|raises?)\b")
|
||||||
|
|
||||||
|
|
||||||
def _parse_param_docs(docstring: str) -> dict[str, str]:
|
def _parse_param_docs(docstring: str) -> dict[str, str]:
|
||||||
"""Extract :param name: description lines from a docstring."""
|
"""Extract :param name: description lines from a docstring."""
|
||||||
params = {}
|
params = {}
|
||||||
@@ -249,9 +252,9 @@ def _parse_param_docs(docstring: str) -> dict[str, str]:
|
|||||||
params[current_param] = " ".join(current_lines).strip()
|
params[current_param] = " ".join(current_lines).strip()
|
||||||
current_param = match.group(1)
|
current_param = match.group(1)
|
||||||
current_lines = [match.group(2)]
|
current_lines = [match.group(2)]
|
||||||
elif current_param and stripped and not stripped.startswith(":"):
|
elif current_param and stripped and not _FIELD_MARKER.match(stripped):
|
||||||
current_lines.append(stripped)
|
current_lines.append(stripped)
|
||||||
elif stripped.startswith(":") or (stripped == "" and current_param):
|
elif _FIELD_MARKER.match(stripped) or (stripped == "" and current_param):
|
||||||
if current_param:
|
if current_param:
|
||||||
params[current_param] = " ".join(current_lines).strip()
|
params[current_param] = " ".join(current_lines).strip()
|
||||||
current_param = None
|
current_param = None
|
||||||
@@ -273,7 +276,7 @@ def _parse_return_doc(docstring: str) -> str:
|
|||||||
in_return = True
|
in_return = True
|
||||||
lines = [match.group(1)]
|
lines = [match.group(1)]
|
||||||
elif in_return:
|
elif in_return:
|
||||||
if stripped.startswith(":") or stripped == "":
|
if _FIELD_MARKER.match(stripped) or stripped == "":
|
||||||
break
|
break
|
||||||
lines.append(stripped)
|
lines.append(stripped)
|
||||||
return re.sub(r"\s+", " ", " ".join(lines).strip())
|
return re.sub(r"\s+", " ", " ".join(lines).strip())
|
||||||
|
|||||||
Reference in New Issue
Block a user