From a95c9fcaab8ba2b7e3916b57eddc3f74e83c0ff3 Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Fri, 20 Mar 2026 22:14:27 +0000 Subject: [PATCH] ifcedit discover: fix param/return doc truncation on RST inline roles Generated with the assistance of an AI coding tool. --- src/ifcedit/ifcedit/discover.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ifcedit/ifcedit/discover.py b/src/ifcedit/ifcedit/discover.py index 3828cf989b..9ebab10534 100644 --- a/src/ifcedit/ifcedit/discover.py +++ b/src/ifcedit/ifcedit/discover.py @@ -236,6 +236,9 @@ def _parse_docstring_body(docstring: str) -> tuple[str, str]: return summary, long_description +_FIELD_MARKER = re.compile(r":(?:param|returns?|rtype|type|raises?)\b") + + def _parse_param_docs(docstring: str) -> dict[str, str]: """Extract :param name: description lines from a docstring.""" params = {} @@ -249,9 +252,9 @@ def _parse_param_docs(docstring: str) -> dict[str, str]: params[current_param] = " ".join(current_lines).strip() current_param = match.group(1) 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) - elif stripped.startswith(":") or (stripped == "" and current_param): + elif _FIELD_MARKER.match(stripped) or (stripped == "" and current_param): if current_param: params[current_param] = " ".join(current_lines).strip() current_param = None @@ -273,7 +276,7 @@ def _parse_return_doc(docstring: str) -> str: in_return = True lines = [match.group(1)] elif in_return: - if stripped.startswith(":") or stripped == "": + if _FIELD_MARKER.match(stripped) or stripped == "": break lines.append(stripped) return re.sub(r"\s+", " ", " ".join(lines).strip())