Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add return type to libdoc output #3017
Comments
|
I usually deal with arguments in function. Such as "myvar = arg[1].encode('utf-8')" or other convertions . |
|
Showing return type information in Libdoc output would certainly be useful. The biggest question is how to show that information. Options include:
I think the latter solution is better but this can still be discussed. Anyone interested to implement this? Shouldn't be overly complicated and I'd be happy to help and review pull requests. |
|
Hi @pekkaklarck I am interested in implementing this request. |
|
Sorry @anandaprakash1979 for missing your comment. Are you still interested in looking at this issue? RF 4.0 will contain also other LIbdoc HTML (e.g. #3586) and return value could be added at the same time. We could also think should return value info be added to Libdocs XML outputs (libspec). Do you @fabioz see that as a useful enhancement? If yes, we should submit a separate issue about it. |
|
One thing to decide is how to handle user keywords that use the |
|
For robot keywords it would be interesting that these keywords could return anything. So, for us (imbus) as user of the xml output, we would really be interested into getting an information if a keyword does return or does not return anything. i think also for Libdoc it would be a nice information. |
|
As discussed on Slack, would be nice if the @Keyword decorator allow setting the return type. the proposed syntax: @Keyword(types={'return': int}) It's compatible with how they are represented in func.annotations and would make implementation really easy. (Pekka) Here is the whole slack thread https://robotframework.slack.com/archives/C0K0240NL/p1605819214419400?thread_ts=1604056554.147300&cid=C0K0240NL |


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: intThis 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):
[Return]settingdef(*, named_arg: str) -> intfor 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.