You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Libdoc should format argument names, defaults and types differently #3586
Libdoc shows argument names in format name: type=default (e.g. count: int=1) where both : type and =default are used only when needed. Currently all this is in same font, but adding some styles would be a good idea. If someone has ideas about good styles to use, please tell your ideas in comments or provide a PR!
This is somewhat related to #3578 but because this issue affects only HTML outputs there are no backwards incompatibility concerns. Implementing this already in RF 3.2.2 is thus possible.
Well, I don't have any suggestions for styles, but would it be good idea to look few examples from IDE or how GitHub does colouring for Python type hints. Example GitHub leans to orange with white background and perhaps default values could be bluish. I would lead the argument itself to black.
For me, having the full path to the type declaration is fine but for some this sort of presentation might be "scary" or not very readable. At least when generating html docs, it would be a bit nicer if the paths were to be shown only on tooltips and the "readable" part of the arguments would be like:
That definitely doesn't look good. I think it would be best if the doc just showed locator: LocatorType instead of resolving LocatorType but I don't know is implementing that possible. It probably would be better to submit a separate issue about this.
@pekkaklarck i dont know enough about type annotation internals to make any statements what so ever but if "test" by adding that future import to libdoc is enough, it did not have any effect at least on 3.7.7
I think just changing the splitting of arguments makes (at least in our project, but I would expect similar readability in other KWs with a lot of arguments) the arg doc much more readable. See
Was there agreement on what sort of syntax highlighting was desired and does it require libdoc model changes that are incompatible with old format?
Do I get it right that the enhancement by @xylix just splits arguments to multiple lines? Something like that could be done already in 3.2.2. Could possibly be done conditionally depending on argument count or the length of the whole argument spec. Another alternative would be adding max width to the argument column.
Actual syntax highlighting requires bigger changes to Libdoc model. Don't think it's safe in 3.2.2.
Generally speaking I would prefer a constant style with arguments (all formated in the same way, regardless of the number or length), because constant style makes it easier to read. From the users point of view, they may prefer current style or each argument splitted to own line and it might make better to provide a command line argument to choose which style is they prefer.
Other option could be that if library uses typing hints then all keywords arguments would be splitting to own lines. This makes easier to read the arguments and their types. And if typing hints are not present, arguments would use the current style.
Libdoc getting some kind of built-in help explaining the argument syntax would be great as well. It could get a separate issue or be implemented as part of this one.
Activity
pekkaklarck commentedon Jun 1, 2020
Moved to 3.3 scope because:
aaltat commentedon Jun 6, 2020
Well, I don't have any suggestions for styles, but would it be good idea to look few examples from IDE or how GitHub does colouring for Python type hints. Example GitHub leans to orange with white background and perhaps default values could be bluish. I would lead the argument itself to black.
rasjani commentedon Jun 23, 2020
Sorry if this is not applicable to this issue but it talked about formatting arguments in libdoc.
I have type hints like this within my source code:
Where LocatorType previously defined as:
In the docs this looks this:
For me, having the full path to the type declaration is fine but for some this sort of presentation might be "scary" or not very readable. At least when generating html docs, it would be a bit nicer if the paths were to be shown only on tooltips and the "readable" part of the arguments would be like:
and then, when hovering on, say, "WebElement" string, there would be tooltip (for example, with span tag and title) shown with full type information.
pekkaklarck commentedon Jun 23, 2020
That definitely doesn't look good. I think it would be best if the doc just showed
locator: LocatorTypeinstead of resolvingLocatorTypebut I don't know is implementing that possible. It probably would be better to submit a separate issue about this.pekkaklarck commentedon Jun 23, 2020
Could you @rasjani test does
from __future__ import annotationshelp? For more details about it and why it could help see https://www.python.org/dev/peps/pep-0563/.rasjani commentedon Jun 25, 2020
@pekkaklarck i dont know enough about type annotation internals to make any statements what so ever but if "test" by adding that future import to libdoc is enough, it did not have any effect at least on 3.7.7
xylix commentedon Aug 13, 2020
I think just changing the splitting of arguments makes (at least in our project, but I would expect similar readability in other KWs with a lot of arguments) the arg doc much more readable. See


Was there agreement on what sort of syntax highlighting was desired and does it require libdoc model changes that are incompatible with old format?
Snooz82 commentedon Aug 20, 2020
@xylix Kerkko,
You changed this already in libdoc, right?
Could you do a PR, then Maybe @pekkaklarck could put it this min improvement to 3.2.2
pekkaklarck commentedon Aug 20, 2020
Do I get it right that the enhancement by @xylix just splits arguments to multiple lines? Something like that could be done already in 3.2.2. Could possibly be done conditionally depending on argument count or the length of the whole argument spec. Another alternative would be adding max width to the argument column.
Actual syntax highlighting requires bigger changes to Libdoc model. Don't think it's safe in 3.2.2.
aaltat commentedon Aug 20, 2020
Generally speaking I would prefer a constant style with arguments (all formated in the same way, regardless of the number or length), because constant style makes it easier to read. From the users point of view, they may prefer current style or each argument splitted to own line and it might make better to provide a command line argument to choose which style is they prefer.
Other option could be that if library uses typing hints then all keywords arguments would be splitting to own lines. This makes easier to read the arguments and their types. And if typing hints are not present, arguments would use the current style.
5 remaining items
pekkaklarck commentedon Oct 20, 2020
Libdoc getting some kind of built-in help explaining the argument syntax would be great as well. It could get a separate issue or be implemented as part of this one.
mkorpela commentedon Oct 28, 2020
Snooz82 commentedon Oct 30, 2020
Done
Make ArgumentSpec iterable so that it yields ArgInfo objects
Libdoc: Document listing Enums and TypedDicts automatically. (#3783)