Skip to content

Commit 0803339

Browse files
committed
Fix missing artist property reference for _CollectionWithSizes.set_sizes
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
1 parent 46ea8f0 commit 0803339

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

doc/missing-references.json

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -143,38 +143,6 @@
143143
]
144144
},
145145
"py:meth": {
146-
"matplotlib.collections._CollectionWithSizes.set_sizes": [
147-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.barbs:180",
148-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.broken_barh:85",
149-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.fill_between:122",
150-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.fill_betweenx:122",
151-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.hexbin:218",
152-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.pcolor:187",
153-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.quiver:256",
154-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.scatter:174",
155-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.AsteriskPolygonCollection.set:45",
156-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.CircleCollection.set:45",
157-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.FillBetweenPolyCollection.set:46",
158-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PathCollection.set:45",
159-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PolyCollection.set:45",
160-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PolyQuadMesh.set:45",
161-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.RegularPolyCollection.set:45",
162-
"lib/matplotlib/collections.py:docstring of matplotlib.artist.StarPolygonCollection.set:45",
163-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.barbs:180",
164-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.broken_barh:85",
165-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.fill_between:122",
166-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.fill_betweenx:122",
167-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.hexbin:218",
168-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.pcolor:187",
169-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.quiver:256",
170-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.scatter:174",
171-
"lib/matplotlib/quiver.py:docstring of matplotlib.artist.Barbs.set:46",
172-
"lib/matplotlib/quiver.py:docstring of matplotlib.artist.Quiver.set:46",
173-
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Barbs:213",
174-
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Quiver:292",
175-
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Path3DCollection.set:47",
176-
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Poly3DCollection.set:46"
177-
],
178146
"matplotlib.collections._MeshData.set_array": [
179147
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.pcolormesh:168",
180148
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PolyQuadMesh.set:17",

lib/matplotlib/artist.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,13 @@ def aliased_name(self, s):
15721572
'matplotlib.image._ImageBase.set_resample',
15731573
'matplotlib.text._AnnotationBase.set_annotation_clip',
15741574
}
1575+
_LINK_IN_CHILD_CLASS = {
1576+
# A set of property setter methods that are inherited, and where the
1577+
# original method is not part of the docs (e.g. because it's in a private
1578+
# base class which is not documented), but the method is documented in
1579+
# the class itself because of :inherited-members:.
1580+
'_CollectionWithSizes.set_sizes',
1581+
}
15751582

15761583
def aliased_name_rest(self, s, target):
15771584
"""
@@ -1640,8 +1647,12 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
16401647
break
16411648
else: # No docstring available.
16421649
method = getattr(self.o, f"set_{prop}")
1643-
prop_and_qualnames.append(
1644-
(prop, f"{method.__module__}.{method.__qualname__}"))
1650+
1651+
if method.__qualname__ in self._LINK_IN_CHILD_CLASS:
1652+
qualname = f"{method.__module__}.{self.o.__name__}.{method.__name__}"
1653+
else:
1654+
qualname = f"{method.__module__}.{method.__qualname__}"
1655+
prop_and_qualnames.append((prop, qualname))
16451656

16461657
names = [self.aliased_name_rest(prop, target)
16471658
.replace('_base._AxesBase', 'Axes')

0 commit comments

Comments
 (0)