pitrou commented on a change in pull request #8457:
URL: https://github.com/apache/arrow/pull/8457#discussion_r505565340



##########
File path: python/pyarrow/compute.py
##########
@@ -47,34 +47,60 @@
 import pyarrow as pa
 
 
+def _get_arg_names(func):
+    arg_names = func._doc.arg_names
+    if not arg_names:
+        if func.arity == 1:
+            arg_names = ["arg"]
+        elif func.arity == 2:
+            arg_names = ["left", "right"]
+        else:
+            raise NotImplementedError(
+                "unsupported arity: {}".format(func.arity))
+
+    return arg_names
+
+
 def _decorate_compute_function(wrapper, exposed_name, func, option_class):
     wrapper.__arrow_compute_function__ = dict(name=func.name,
                                               arity=func.arity)
     wrapper.__name__ = exposed_name
     wrapper.__qualname__ = exposed_name
 
-    # TODO (ARROW-9164): expose actual docstring from C++
     doc_pieces = []
-    arg_str = "arguments" if func.arity > 1 else "argument"
+
+    cpp_doc = func._doc
+    summary = cpp_doc.summary
+    if not summary:
+        arg_str = "arguments" if func.arity > 1 else "argument"
+        summary = ("Call compute function {!r} with the given {}"
+                   .format(func.name, arg_str))
+
+    description = cpp_doc.description
+    arg_names = _get_arg_names(func)
+
     doc_pieces.append("""\
-        Call compute function {!r} with the given {}.
+        {}.
+
+        """.format(summary))
 
+    if description:
+        doc_pieces.append("{}\n\n".format(description))
+
+    doc_pieces.append("""\
         Parameters
         ----------
-        """.format(func.name, arg_str))
+        """)
 
-    if func.arity == 1:
+    for arg_name in arg_names:
+        if func.kind in ('vector', 'scalar_aggregate'):
+            arg_type = 'Array-like'
+        else:
+            arg_type = 'Array-like or scalar-like'

Review comment:
       Perhaps, yes.




----------------------------------------------------------------
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.

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


Reply via email to