-
Notifications
You must be signed in to change notification settings - Fork 6
draft for pandas examples support #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| ?start : doctype | ||
|
|
||
| doctype : type_or ("," optional)? ("," extra_info)? | ||
| doctype : (literals | type_or) ("," optional)? ("," extra_info)? | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Restricting work. Do you find that readable? Though, working is something. 😅
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See 5a28828.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had never seen nor considered that option, but now thinking about it there are a couple places I could use it. If you use it or feel strongly about it maybe we could use something similar to arrays for mappings in the sense a subset of names are allowed, and only if they are present can then curly brackets indicate two subtypes with colon. My guess is dict and mapping alone will cover 90% of the cases, maybe mutablemapping could also be there. Plus a way to extend those names for both dict and array (to allow tensor for example in projects that use it)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think it might be more confusing if we restricted who can use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to keep literals as top level option only |
||
|
|
||
| type_or : type (("or" | "|") type)* | ||
|
|
||
| literals : "{" literal (("," | "or") literal)* "}" | ||
|
|
||
| ?type : qualname | ||
| | "{" literal ("," literal)* "}" -> literals | ||
| | container_of | ||
| | shape_n_dtype | ||
|
|
||
|
|
@@ -23,7 +24,9 @@ contains: "[" type_or ("," type_or)* "]" | |
|
|
||
|
|
||
| // Container-of | ||
| container_of : NAME "of" type_or | ||
| container_of : NAME "of" ( type_or | dict_subtypes ) | ||
|
|
||
| dict_subtypes : "{" type_or ":" type_or "}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, you made me release that we can streamline this and get rid of contains: "[" type_or ("," type_or)* "]"
| "[" type_or "," PY_ELLIPSES "]"
| "of" type
| "of" "(" type_or ("," type_or)* ")"
| "of" "{" type_or ":" type_or "}"That setup also makes it so that one has to enclose in (BTW amazing that GitHub highlights Lark syntax!)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See 3908f3f.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is great, I'll also open an issue or PR to numpydoc itself with these at some point. I have never known how "list of int or float" is supposed to be interpreted (list of int) or float vs list of (int or float)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intuitively I'd say Part of the aim behind docstub is also to create some kind of standard, with the understanding that "hey if you want something more custom you need to configure it yourself" . I don't remember who but someone from NumPyDoc told me at some point they'd be happy to go with whatever recommendation docstub settles on.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It doesn't have to because Python's type annotation for dicts |
||
|
|
||
|
|
||
| // Array-like form with dtype or shape information | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pandas's type syntax seems a bit dubious. I guess this is equivalent to
and the alternating
oris for grouping of equivalent values?This might be a case I'd leave a third party to configure itself and not support it directly in docstub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they do use the or to indicate equivalent meaning literals, the comma to indicate different meaning literals. I have never used the or in literals though