aarmens702-hub commented on code in PR #76701:
URL: https://github.com/apache/airflow/pull/76701#discussion_r4516196719


##########
providers/common/ai/src/airflow/providers/common/ai/toolsets/hook.py:
##########
@@ -502,20 +502,30 @@ def _extract_description(method: Callable[..., Any]) -> 
str:
 
 
 # Matches Sphinx-style `:param name:` and Google-style `name:` under an 
``Args:`` block.
-_SPHINX_PARAM_RE = re.compile(r":param\s+(\w+):\s*(.+?)(?=\n\s*:|$)", 
re.DOTALL)
+_SPHINX_PARAM_RE = re.compile(r"^(\s*):param\s+(\w+):(.*)$")
 _GOOGLE_ARGS_RE = re.compile(r"^\s{2,}(\w+)\s*(?:\(.+?\))?:\s*(.+)", 
re.MULTILINE)
 
 
 def _parse_param_docs(docstring: str) -> dict[str, str]:
     """Parse parameter descriptions from Sphinx or Google-style docstrings."""
     params: dict[str, str] = {}
 
-    # Try Sphinx style first.
-    for match in _SPHINX_PARAM_RE.finditer(docstring):
-        name = match.group(1)
-        desc = " ".join(match.group(2).split())
-        params[name] = desc
+    # Try Sphinx style first. As in a reStructuredText field list, a 
description runs on
+    # through the lines indented deeper than its ``:param`` line, so neither a 
continuation
+    # line starting with a role such as ``:class:`` nor an example block after 
the last
+    # parameter changes where it ends.
+    name: str | None = None
+    indent = 0
+    for line in docstring.splitlines():
+        if match := _SPHINX_PARAM_RE.match(line):
+            name, indent = match.group(2), len(match.group(1))
+            params[name] = match.group(3)
+        elif name and (not line.strip() or len(line) - len(line.lstrip()) > 
indent):

Review Comment:
   Done in f0a4299: indented the continuation line and added partner_id's 
colon. I also scanned every provider hook for a continuation line at the same 
indent as its :param, or a :param with no colon, and erf_uri was the only one.
   
   Drafted-by: Claude Code following the guidelines



##########
providers/common/ai/tests/unit/common/ai/toolsets/test_hook.py:
##########
@@ -782,6 +782,58 @@ def test_sphinx_style(self):
         assert result["name"] == "The name of the thing."
         assert result["count"] == "How many items."
 
+    def test_sphinx_last_param_stops_at_dedented_text(self):

Review Comment:
   Added test_sphinx_description_continues_after_a_blank_line, shaped like 
copy_object's source_bucket_key. It fails if the `not line.strip()` check is 
removed.
   
   Drafted-by: Claude Code following the guidelines



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to