10000 Fix missing artist property reference for _CollectionWithSizes.set_sizes by timhoffm · Pull Request #29560 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix missing artist property reference for _CollectionWithSizes.set_sizes #29560

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

Closed
wants to merge 1 commit into from

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Feb 1, 2025

Child classes of _CollectionWithSizes that list all their properties via "%(MyClass:kwdoc)s" want to reference _CollectionWithSizes.set_sizes, but that is not documented because _CollectionWithSizes is not documented.

Since all the child classes are documented with the option :inherited-members:, the child classes all explicitly document set_sizes themselves. This PR changes the link target to that.

This fixes the broken link in all docstrings that list the possible kwarg values for collections such as in https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.broken_barh.html:
grafik

It also removes the need for _CollectionWithSizes.set_sizes entries in missing-references.json. This is important because the docstring line numbers that are hard-coded in there can change due to introduction of new properties or changes in the docstring above the "%(MyClass:kwdoc)s" placeholder, which has repeatedly lead to doc failures - latest affected PR is #29044 - and is really annoying.


Note: One could alternatively consider documenting _CollectionWithSizes explicitly or even making it public. But these are larger decisions that I don't want to go into now, because that means reconsidering using the :inherited-members: for Collections documentation or even compatibility concerns when making it public.

The fix here is well contained and can be reverted or adapted as needed in the future.

8000

Child classes of `_CollectionWithSizes` that list all their properties
via "%(MyClass:kwdoc)s"
want to reference `_CollectionWithSizes.set_sizes`, but that is not
documented because `_CollectionWithSizes` is not documented.

Since all the child classes are documented with the option
`:inherited-members:`, the child classes all explicitly document
`set_sizes` themselves. This PR changes the link target to that.

Note: One could consider documenting `_CollectionWithSizes`
explicitly or even making it public. But these are larger decisions that
 I don't want to go into now, because that means reconsidering
 using the `:inherited-members:` for Collections documentation or even
 compatibility concerns when making it public.

The fix here is well contained and can be reverted or adapted as needed
in the future. It's an important fix because it removes `set_sizes` from
 `missing-references.json`. The docstring line numbers that are
 hard-coded in there can change due to introduction of new properties or
  changes in the docstring above the "%(MyClass:kwdoc)s" placeholder,
  which has repeatedly lead to doc failures - latest affected PR is
  matplotlib#29044 - and is really annoying.

 there
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Feb 1, 2025
This is needed to get `_CollectionWithSizes.set_sizes` documented so
that it can be referenced.

Alternative approach to matplotlib#29560.
@timhoffm timhoffm marked this pull request as draft February 1, 2025 15:16
@timhoffm
Copy link
Member Author
timhoffm commented Feb 1, 2025

Does not completely as intended. Not all child classes are generated with :inherited-members. These are not covered and fail:

/home/circleci/project/lib/matplotlib/quiver.py:docstring of matplotlib.artist.Barbs.set:46: WARNING: py:meth reference target not found: matplotlib.collections.Barbs.set_sizes [ref.meth]
/home/circleci/project/lib/matplotlib/quiver.py:docstring of matplotlib.artist.Quiver.set:46: WARNING: py:meth reference target not found: matplotlib.collections.Quiver.set_sizes [ref.meth]
/home/circleci/project/lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Path3DCollection.set:47: WARNING: py:meth reference target not found: matplotlib.collections.Path3DCollection.set_sizes [ref.meth]
/home/circleci/project/lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Poly3DCollection.set:46: WARNING: py:meth reference target not found: matplotlib.collections.Poly3DCollection.set_sizes [ref.meth]

They fail because they are sub-subclasses that do use :inherited-members:. One could try to find the right level to link to, but I will first try whether a minimal documentation of _CollectionWithSizes may be better.

timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Feb 1, 2025
This is needed to get `_CollectionWithSizes.set_sizes` documented so
that it can be referenced.

Alternative approach to matplotlib#29560.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Feb 1, 2025
This is needed to get `_CollectionWithSizes.set_sizes` documented so
that it can be referenced.

Alternative approach to matplotlib#29560.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Feb 1, 2025
This is needed to get `_CollectionWithSizes.set_sizes` documented so
that it can be referenced.

Alternative approach to matplotlib#29560.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Feb 1, 2025
This is needed to get `_CollectionWithSizes.set_sizes` documented so
that it can be referenced.

Alternative approach to matplotlib#29560.
@timhoffm
Copy link
Member Author
timhoffm commented Feb 1, 2025

Closing in favor of #29561

@timhoffm timhoffm closed this Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0