-
Notifications
You must be signed in to change notification settings - Fork 789
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
feat: expr
method signatures
#3600
Draft
dangotbanned
wants to merge
68
commits into
main
Choose a base branch
from
vega-expr-gen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+2,126
−794
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Similar idea to `inspect.Parameter`
Similar to `inspect.Signature`
- Only the most common case - no docs - No method body
Currently just collects the pieces, but doesn't render the final str
Also renamed constant `EXPR_ANNOTATION` -> `INPUT_ANNOTATION`
- Contains all the functionality - Needs a lot of tidying up
- Uses the same config as `indent_docstring` - Can't truly be `numpydoc` though without a parameters section
This was referenced Sep 21, 2024
dangotbanned
commented
Sep 23, 2024
dangotbanned
commented
Sep 25, 2024
Comment on lines
+1052
to
+1057
The optional ``specifiers`` object provides a set of specifier sub-strings for customizing | ||
the format; for more, see the `timeUnitSpecifier API documentation`_. The resulting | ||
specifier string can then be used as input to the `timeFormat`_ or `utcFormat`_ functions, | ||
or as the *format* parameter of an axis or legend. For example: ``alt.expr.timeFormat(date, | ||
alt.expr.timeUnitSpecifier('year'))`` or ``alt.expr.timeFormat(date, | ||
alt.expr.timeUnitSpecifier(['hours', 'minutes']))``. |
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.
Inline -> block code idea
An example of how this change would show
def func(*args):
"""
...
The optional ``specifiers`` object provides a set of specifier sub-strings for customizing
the format; for more, see the `timeUnitSpecifier API documentation`_. The resulting
specifier string can then be used as input to the `timeFormat`_ or `utcFormat`_ functions,
or as the *format* parameter of an axis or legend.
Examples
--------
>>> alt.expr.timeFormat(date, alt.expr.timeUnitSpecifier('year'))
>>> alt.expr.timeFormat(date, alt.expr.timeUnitSpecifier(['hours', 'minutes']))
"""
...
Issues
- Some of these uses the pattern
"... -> result"
- This can be recreated using the doctest syntax
- but the actual result won't be the same as what is stated, since they are not evaluated
alt.expr.format
uses a different style- "(e.g.,
alt.expr.format(value, ',.2f')
" - Whereas all the others use (
"For example:..."
|"Example:..."
)
- "(e.g.,
Also some rearranging in `vega_expr.py`
dangotbanned
commented
Sep 25, 2024
tools/schemapi/vega_expr.py
Outdated
Comment on lines
198
to
219
def _doc_fmt(doc: str, /) -> str: | ||
""" | ||
FIXME: Currently doing too many things. | ||
|
||
Primarily using to exclude summary line + references from ``textwrap``. | ||
""" | ||
sentences: deque[str] = deque(SENTENCE_BREAK.split(doc)) | ||
if len(sentences) > 1: | ||
references: str = "" | ||
summary = f"{sentences.popleft()}.\n" | ||
last_line = sentences.pop().strip() | ||
sentences = deque(f"{s}. " for s in sentences) | ||
if "\n\n.. _" in last_line: | ||
last_line, references = last_line.split("\n\n", maxsplit=1) | ||
sentences.append(last_line) | ||
sentences = deque(text_wrap.wrap("".join(sentences))) | ||
sentences.appendleft(summary) | ||
if references: | ||
sentences.extend(("", indent(references, 8 * " "))) | ||
return "\n".join(sentences) | ||
else: | ||
return sentences.pop().strip() |
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.
Issues
- Very tightly coupled to how
RSTRenderer
appends links - Don't think
re.split
is that intuitive, despite working for this specfic case - Would prefer something more structured
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
dangotbanned
commented
Sep 25, 2024
Also moved some static content to template and simplified #3600 (comment), #3600 (comment), #3600 (comment)
The `EXPR_` prefix is meaningless when all use it
- Both have a `.from_..()` iterator classmethod - Both output via `.render()` #3600 (comment)
dangotbanned
commented
Sep 26, 2024
- Moves a replacement that previously occured in two places (rendering & signatuyre parsing) - Now the tokens returned by `read_ast_tokens` do not contain this at all #3600 (comment)
Step is unrelated to parsed attributes of a definition
This method was always intended to be temorary and is no longer helpful
Related to (but doesn't resolve) #3600 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Will close #3563
Description
placeholder - fill before leaving draft
Tasks
py
-equivalent signaturesaltair
functionsbackticks
for own parametersmistune
escapingtest_expr.py
to account for number of arguments relatedalt.expr.__init__.py
.rst
stuff commitvega_expr.py
expr
method signatures #3600 (review)Deferred
expressions.md
tools.schemapi.vega_expr.py
->tools.vega_expr.py
vega-lite
schemaexpr
methods, replace w/ snake_case_ExprMeta.__getattr__
would make this possibleRelated
expr
as a class that is understood by IDEs #3466expr
as a class that is understood by IDEs #3466 (comment)expr
as a class that is understood by IDEs #3466 (comment)Preview
Prior to
5e75051
(#3600) there wasn't any generated source on this branch.Keeping these screenshots for a quick reference
until I've resolved some test issues.Screenshots