Skip to content

Remove outdated docstring section in RendererBase.draw_text. #28380

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

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 12, 2024

The line of code mentioned in the docstring has been removed since e50ff69, back in 2004...

Replace with a comment in the code, closer to the place relevant for metrics calculations.

PR summary

PR checklist

@anntzer anntzer changed the title Remove outdated comment in RendererBase.draw_text. Remove outdated docstring section in RendererBase.draw_text. Jun 12, 2024
@@ -604,6 +590,9 @@ def get_text_width_height_descent(self, s, prop, ismath):

Whitespace at the start and the end of *s* is included in the reported width.
"""
# Note: Using the ``bbox`` property of Text objects, backend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear how this relates to the context.

What exactly do backend implementors implement? Do they reimplement this function?
Also, how do they check? Do they draw a text and additionally its bbox? Would a minimal example be helpful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, like most renderer methods get_text_width_height_descent can be reimplemented by third-party backends (or not, depending on how exactly they do their text rendering). Drawing the bbox (via text.set_bbox(...)) lets them check that get_text_width_height_descent indeed returns the right value.
I'm not really sure a full example would be very useful, and even if it is, it would only be useful for rendering backend authors (of which there may be 10 or so right now in the world) so I would not bother. Alternatively we could just completely remove the comment...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the comment is not useful as is. Either you already know the context and then likely don't need it, or it's too terse and you still don't know how to apply it. I'm fine going either way, removing or expanding.

Copy link
Contributor Author

@anntzer anntzer Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just kill it, then. Amended the commit.

The line of code mentioned in the docstring has been removed since
e50ff69, back in 2004...
@timhoffm timhoffm added this to the v3.9.1 milestone Jun 13, 2024
@timhoffm timhoffm merged commit 5d6acdf into matplotlib:main Jun 13, 2024
39 of 42 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jun 13, 2024
@anntzer anntzer deleted the bba branch June 13, 2024 14:40
timhoffm added a commit that referenced this pull request Jun 13, 2024
…380-on-v3.9.x

Backport PR #28380 on branch v3.9.x (Remove outdated docstring section in RendererBase.draw_text.)
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.

2 participants