Skip to content
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: Generate docstrings for mark_ methods #3675

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Conversation

dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Nov 4, 2024

Closes #3262

Description

This PR is a 2-for-1.

  1. Primarily Add autogenerated docstrings to mark_ methods #3262
  2. But also reduces mixins.py from 3500 to 1600 lines

What I've done here is created a dummy version of each class, where the only difference is the omission of type.
The dummy is used only for the signature & docstring.

If we used core.MarkDef directly, it always displays type first.
I'm assuming that wouldn't be desirable - since we set that explicitly in the method body

Example

IDE

2024-11-04.19-20-41.mp4

API reference

Remains unchanged

image

@dangotbanned dangotbanned marked this pull request as ready for review November 4, 2024 19:44
@mattijn
Copy link
Contributor

mattijn commented Nov 4, 2024

If I recall correctly, not every mark supports the same variable definitions, do you assume here that all marks can use the same MarkDef? Btw, I've no supporting materials yet that supports my assumption.

@dangotbanned
Copy link
Member Author

@mattijn thanks for looking at this so soon!

If I recall correctly, not every mark supports the same variable definitions, do you assume here that all marks can use the same MarkDef? Btw, I've no supporting materials yet that supports my assumption.

Just to be sure I understand what you mean, are you referring to this old comment?

marks: list[Any] = _def["enum"] if "enum" in _def else [_def["const"]]
for mark in marks:
# TODO: only include args relevant to given type?
mark_method = MARK_METHOD.format(
decorator=f"_{mark_def}", mark=mark, mark_def=mark_def
)

I've interpretted that as meaning how the docs for MarkDef has some descriptions which state they only apply for specific marks (e.g. x2 applies to {"area", "bar", "rect", "rule"}).

If so, I don't think there would be a reliable way to do that - since the descriptions aren't written in a consistent style.


Or did you mean core.MarkDef vs the composite marks?

class _BoxPlotDef(SchemaBase):

class _ErrorBarDef(SchemaBase):

class _ErrorBandDef(SchemaBase):

If so, then yeah these are split out correctly

@mattijn
Copy link
Contributor

mattijn commented Nov 4, 2024

I mean the latter. Good to see that the composite marks are still treated differently, but I thought that not all arguments can be used within the standard marks. It seems that it was and will be covered by just the MarkDef.

dangotbanned added a commit that referenced this pull request Nov 5, 2024
Will look at fixing `mixins` after merging #3675
@mattijn mattijn merged commit 7b3d479 into main Nov 6, 2024
25 checks passed
@mattijn
Copy link
Contributor

mattijn commented Nov 6, 2024

Thanks!

@dangotbanned
Copy link
Member Author

Thanks!

Appreciate the review thanks @mattijn

@dangotbanned dangotbanned deleted the gen-docs-mark-methods branch November 6, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add autogenerated docstrings to mark_ methods
2 participants