Closed
Description
With the support of type-hints Python signatures can give information on the type of returned values of a method. This could be used to improve the documentation generated by libdoc.
def my_func(foo: str, count: int) -> str:
will give the following in the Argument column:
foo: str, count: int
This could be expanded to include the type of the returned value:
foo: str, count: int -> str
(following the Python notation)
The header Arguments could be updated to Signature to reflect this additional information.
Things to consider (from Slack conversation):
- Take into account user keywords that may have used
[Return]
setting - How to handle
def(*, named_arg: str) -> int
for forced named arguments methods. The resulting signature in the documentation (*, named_arg: str -> int) may confuse users that are not familiar with the new syntax to force named arguments. Note that the * cannot be omitted from the method signature since this would mean the method is no longer named-only. - How to handle types in a signature that are based on the typing module (typing.Union, etc.). Right now, they come up as typing.Union in the documentation, while the inclusion of the standard module (typing.) does not really give the user much information. Also, the more complex typing constructions (Optional, nested structures, etc.) could lead to very long and unusable documentation entries.