-
Notifications
You must be signed in to change notification settings - Fork 795
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
Make signatures and docstrings easy to read again #3290
Comments
I agree that the type hints on the autogenerated Altair classes are too verbose right now and that its leaning too strongly on the "have fully specified type hints" side neglecting somewhat the UX. In the docs, I specifically disabled the type hints from showing up in the class signatures - as shown in your screenshot - but I don't know of a way to do this for IDEs as well. An advantage to the previous state without type hints is, that before one saw all arguments but it was difficult to know what actually needs to be provided. Maybe we can achieve some version in between where we show the most important type hints, in both the docstrings as well as using it in the definitions as well. For example we could not show all specific classes but instead use I think the literals are very useful as they provide documentation as well as autocomplete suggestions. What do you think? Happy to create a PR with these changes so we can play around with how it looks and further take it from there. |
Thanks @binste, your screenshot is a clear improvement to me in terms of readability. I'm happy to review and iterate on a PR! A few comments on your improvements I can see in the screenshot and the comments you made:
|
Thanks for the nice write up!
I'll request your review on the PR once I have it ready. |
|
Re 1., that's great! I hope they are onboard with the suggestion. |
Thank you for updating the PR, I will have a look! Re 4, I was thinking of only including the defaults in the docstring/signature but not in the actual spec that is produced; maybe that's impossible/confusing. And I think they are already mentioned in the docstring text, so it's probably clear enough that Undefined actually becomes a value. Another option would be to use However, it seems like it will be hard to use |
Good point, we could filter out the default values again from the spec although we could then not differentiate if someone intentionally sets a value and it just happens to be the default value or not. This might also not matter. I don't know if any of this is possible but interesting to think about :)
|
I think it is important that our docstrings are easy to read, so that it is easy to quickly look up help without going to the documentation site. Up until altair 5.1.2, the signatures were easy to parse for a human:
Although it is unclear what all the
Undefined
means above, I get a clear, succinct overview of which arguments exist. Since v 5.2, the signatures are now notably harder to read and directly intimidating at first glance:The story is similar for the docstring (although less severe), e.g. it used to be relatively easy to understand what the
sort
parameter does:But now that section is it is non-really understandable:
I think this stems mainly from #3208 so tagging @binste @mattijn @jonmmease since we were all part of the discussion there. Does anyone have ideas of how we can keep the docstrings human readable while keeping the benefits from all the work @binste has put in on making altair properly typed? There are at least two angles here: the formatting of the docstring (which is mostly up to the IDE), and the content (which is entirely up to us). I would be in favor of keeping the old signatures in the help popup if possible; I'm unsure about what is best in the docstring itself.
I only included screenshots from jupyterlab above, but the situation seems to be similar in vscode:
Our online documentation retains the old easy to read signatures (I'm not sure if we added an exception or just haven't regenerated it since 5.2):
Although the docstring for the parameters has updated to the new more verbose syntax:
The text was updated successfully, but these errors were encountered: