Libdoc: Support separate type documentation for arguments and return values
Libdoc shows documentation for recognized types used as arguments and, since RF 7.0 (#3017), as return types. There are four kind of recognized types:
- Standard types (
str,list,Path, ...) - Enums
- TypedDicts
- Custom types
With standard types the shown documentation is part of the Libdoc implementation and with the other types the docs come from the types themselves and are written by library developers.
This system works well in general, but if the same type is used with arguments and also as a return type, writing good documentation that covers both usages can be problematic. Argument type documentation should in general specify what arguments are allowed, while the return type documentation should explain how the return value can be used, what kind of attributes custom objects have, and so on.
A solution to this problem is making it possible to have separate documentation for argument types and return types. This is what getting it done requires in high level:
- Design how to store separate argument and return type docs in Libdoc spec files.
- Update Libdoc HTML UI accordingly.
- Write return type docs for standard types.
- Design how other types can specify return type docs. Currently docs are got from class or function docstrings, and we could support some marker there that would separate different docs. Alternatively classes/functions could have a custom attribute like
type_docthat could be a two-tuple with argument and return type docs separately.
Source: robotframework/robotframework