Skip to content

Fix missing artist property reference for _CollectionWithSizes.set_sizes - #29560

Closed
timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:doc-set_sizes
Closed

timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:doc-set_sizes

Conversation

@timhoffm

@timhoffm timhoffm commented Feb 1, 2025 •

Copy link
Copy Markdown
Member

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.

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

timhoffm commented Feb 1, 2025

Copy link
Copy Markdown
Member Author

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

timhoffm commented Feb 1, 2025

Copy link
Copy Markdown
Member Author

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