-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Libdoc should format argument names, defaults and types differently #3586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Moved to 3.3 scope because:
|
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. |
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: def drag_and_drop(self: "SeleniumTestability", locator: LocatorType, target: LocatorType, html5: bool = False) -> None: Where LocatorType previously defined as: from selenium.webdriver.support.event_firing_webdriver import EventFiringWebElement, EventFiringWebDriver
LocatorType = Union[WebElementType, EventFiringWebElement, str] 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. |
That definitely doesn't look good. I think it would be best if the doc just showed |
Could you @rasjani test does |
@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 Kerkko, You changed this already in libdoc, right? |
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. |
@aaltat from my pov, showing typing hints is really good. Even in a long run too because that exposes a bit of python land to people and exposing same syntax is good. But there are few angles, first: How the type hints are rendered atm is IMO a bit hard to read (this is my main issue) Second: would the "Python bleed" to documentation be considered bad cuz it would give indication that core prefers python ? I don't remember seeing keyword docs made from java or remote libs having the type information shown even thou in java that most likely is very easy to implement. Which also makes me think that from POV of tester writing test data, having 2 different styles for type hints would be a bit weird ? |
#3638 @pekkaklarck Do you have any input on how we should put a part of the HTML template behind a command line flag. Should we do this html base change on python side and only if flag is set? |
I personally don't think this should be controlled by a command line option. This is why:
Anyway, this topic should get its own issue where it can be discussed further. I notice @xylix already created a PR but we'd anyway need an issue for tracking purposes and discussion in the issue is preserved even if the PR would be closed and new created. Could you @xylix create the issue as well? |
Made a tracking issue at #3639 |
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. |
Done |
ArgInfo objects are easy to use for Libdoc when it needs to work with each argument. Helps implementing robotframework#3578 and robotframework#3586.
Also rewrite section explaining how arguments are shown in general because that has been changed by #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.
The text was updated successfully, but these errors were encountered: