The attached patch is a very rough prototype which seems to work (but wasn't tested beyond running pydoc on a number of function(-like) objects.
With the patch the documentation for a callable defined in C but with a __signature__ property shows argument names in the rendered prototype instead of just '(...)' while the documentation for python functions and C functions without a __signature__ also works.
Issues:
* Rendering to HTML is broken if a function has POSITIONAL_ONLY arguments
(the names of those arguments are rendered as '<arg>' and that value
is not escaped in the HTML output)
* This adds a "render" method to inspect.Signature and inspect.Param
to be able to pass custom render function for elements of a signature
and I'm not convinced that this is the right solution.
* There are no unittests for the new code (and I haven't run the existing
tests to check if anything else has broken) |