Repository navigation
Description
Libdoc shows keyword arguments separately and lists their names, "kind" (positional-only, varargs, ...), possible type (str, int, ...) and possible default value. There is, however, no way to include argument documentation in this listing. Instead, arguments need to be documented as part of the normal keyword documentation using whatever approach found usable. Libdoc also shows return value type, but it does not support documentation either.
We should change this and make it possible to specify argument and return value documentation explicitly so that it could be listed along with other argument and return value related information. This syntax should also play well with other tools such as IDEs and API doc generators. In practice we thus should use syntax that's used for arguments with Python normally. Unfortunately there is no official standard for that and different projects have used different approaches. The three most commonly used argument documentation styles are:
- The Sphinx style. This is what we currently use with Robot's API docs. In that usage it has worked fine, but the syntax is pretty complicate and verbose. It also doesn't render nicely as Markdown that we plan to support with Libdoc (Libdoc: Support documentation written with Markdown #5304).
- The NumPy style. This style is used primarily in the scientific Python circles. but nobody would prevent us from using it. It's simpler than the Sphinx style, but it still requires quite a bit of markers and doesn't work with with Markdown.
- The Google style. This is the simplest format and works very well also in source code. An example using this style is below.
def example(first: int, second: float) -> float:
"""Example keyword.
Args:
first: The doc for the first parameter.
second: Also the second parameter has documentation.
It is split to multiple lines.
Return:
The sum of the given arguments.
"""
return a + bThe Google style is my clear favorite. It could be used both with library keywords and user keywords, and we probably could support it both with Markdown and with Robot's own documentation format. The Google style has its own problems, though::
- Also this syntax doesn't work too well with standard Markdown. For example, the block of text starting with
Args:is parsed as a single paragraph so you end up with a paragraph starting withArgs: second: The doc for the first .... The situation gets better if you add an empty line afterArgs:. In that case rest of the block is considered a code block and rendered as preformatted text. Not great but massively better than alternatives. - Also the old Robot format parses the whole
Args:block as a paragraph and this time adding an empty row just causes there to be two paragraphs. We may need to enhance the Robot format to support this argument documentation style better. - The syntax isn't specified in detailed level and there are various flavors with the headers. The spec I linked above lists headers
Args:,Returns:/Yields:andRaises:, but I've seen also seenArgs:replaced withArguments:andParameters:and some extra headers being used. - The syntax supports type information in documentation like
first (int): The doc .... That was useful in Python 2 days, but nowadays it's better to use annotations and the linked docs don't even show this syntax (see here for an example that shows it). I believe we should understand this syntax, but I also believe we should just ignore the type information. We don't want to parse keyword docs during execution for performance reasons, so the type information wouldn't actually be used and showing it in Libdoc UI would be misleading.
Luckily we can solve these problems with some extra work:
- Decide which flavor of the Google style we support. This includes deciding which headers to support and whether we should support specifying argument types (type hints generally work better).
- Implement a parser for the flavor we support. It should read argument docs so that we can add them to Libdoc model along with argument names and types. Docs should then be shown in the Libdoc UI along with other argument information.
- Remove argument documentation from the overall docs. No need to show the same information twice and this also avoids problems with Markdown formatting.
Activity
Huaian666 commentedon Jun 12, 2026
was just about to open the same issue. the current docs skip over this part entirely. had to read source
[-]Libdoc: Dedicated syntax for argument and return value documentation[/-][+]Libdoc: Argument and return value documentation syntax[/+]pekkaklarck commentedon Jun 16, 2026
While reviewing #5684 I noticed there are two design decisions to be made:
According to the spec, varargs and kwargs should be documented using
*argsand**kwssyntax, respectively. We obviously should follow the spec here and allow documentation like*args: The doc. The question is, should we also support omitting*and**likeargs: The doc? I believe that makes sense in general and I'm afraid reporting error if someone has usedargswhen we require*argswould also be complicated.What syntax to use with user keyword arguments? Alternatives are requiring either
arg: The docor${arg}: The docand supporting both. I don't have strong preference between either of the alternatives and believe supporting both would be simplest. If I needed to choose one syntax, I'd go witharg: The doc, because we only showarg, not${arg}in Libdoc HTML docs. Not supporting${arg}: The docwhen the actual signature uses${arg}would likely be confusing, though, and also in this case error reporting if someone has used the wrong format would be complicated.Both of the above could be implemented in the lower level documentation parser so that it normalizes names. In practice
*arg,**arg,${arg},@{arg}and&{arg}should all be normalized toarg. We could implement this so that the first two work only with library keywords and the last three only with user keywords, but I see no concrete benefits with that.Notice that internally the
ArgumentSpecobject anyway stores only argument names without any decoration. We thus need to normalize names at some point anyway.15 remaining items
libdoc: parse raises documentation
Libdoc: Document 'Raises:' support
Libdoc: Fix parsing docstring info with dynamic library `__init__`
Enhance parsing keyword tags from documentation
Refactor parsing information from keyword documentation.
pekkaklarck commentedon Jul 15, 2026
After my previous comment we have done, at least, the following:
Raises:section is handled. This information is added to the spec files and shown in the UI.Tags:section has been improved (Enhance parsing tags from keyword documentation #5707).See the linked commits above for more details. After all this we can consider this issue done. We can still make adjustments to the UI styles if needed.
Documentation enhancements
Libdoc: Support argument documentation as list.
Finetune Libdoc docs related formatting argument docs
Libdoc: Style enhancements (#5742)