Skip to content

Commit 9a0bde7

Browse files
committed
Fix broken references.
In particular, the property table for artists was changed to point links to the parent method which actually provides the docstring, if the docstring is inherited.
1 parent 7543b13 commit 9a0bde7

File tree

7 files changed

+63
-78
lines changed

7 files changed

+63
-78
lines changed

doc/api/axis_api.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Interactive
146146
:template: autosummary.rst
147147
:nosignatures:
148148

149-
149+
Axis.contains
150150
Axis.get_pickradius
151151
Axis.set_pickradius
152152

doc/missing-references.json

+20-27
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@
175175
"doc/api/prev_api_changes/api_changes_2.2.0.rst:215"
176176
],
177177
"Patch3DCollection": [
178-
"doc/api/toolkits/mplot3d.rst:92:<autosummary>:1"
178+
"doc/api/toolkits/mplot3d.rst:83:<autosummary>:1"
179179
],
180180
"Path3DCollection": [
181-
"doc/api/toolkits/mplot3d.rst:92:<autosummary>:1"
181+
"doc/api/toolkits/mplot3d.rst:83:<autosummary>:1"
182182
],
183183
"_FancyAxislineStyle.FilledArrow": [
184184
"<unknown>:1"
@@ -207,15 +207,15 @@
207207
],
208208
"matplotlib.axes._axes.Axes": [
209209
"doc/api/artist_api.rst:189",
210-
"doc/api/axes_api.rst:686",
210+
"doc/api/axes_api.rst:613",
211211
"lib/matplotlib/projections/polar.py:docstring of matplotlib.projections.polar.PolarAxes:1",
212212
"lib/mpl_toolkits/axes_grid1/mpl_axes.py:docstring of mpl_toolkits.axes_grid1.mpl_axes.Axes:1",
213213
"lib/mpl_toolkits/axisartist/axislines.py:docstring of mpl_toolkits.axisartist.axislines.Axes:1",
214214
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D:1"
215215
],
216216
"matplotlib.axes._base._AxesBase": [
217217
"doc/api/artist_api.rst:189",
218-
"doc/api/axes_api.rst:686",
218+
"doc/api/axes_api.rst:613",
219219
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes:1"
220220
],
221221
"matplotlib.backend_bases.FigureCanvas": [
@@ -380,8 +380,6 @@
380380
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fixed:1",
381381
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fraction:1",
382382
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxExtent:1",
383-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxHeight:1",
384-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxWidth:1",
385383
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Padded:1",
386384
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Scaled:1",
387385
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.SizeFromFunc:1"
@@ -593,7 +591,7 @@
593591
"doc/devel/contributing.rst:546"
594592
],
595593
"Artist.sticky_edges": [
596-
"doc/api/axes_api.rst:357:<autosummary>:1",
594+
"doc/api/axes_api.rst:362:<autosummary>:1",
597595
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.use_sticky_edges:2"
598596
],
599597
"ArtistInspector.aliasd": [
@@ -612,12 +610,12 @@
612610
"doc/users/prev_whats_new/whats_new_3.1.0.rst:247"
613611
],
614612
"Axes.dataLim": [
615-
"doc/api/axes_api.rst:297:<autosummary>:1",
613+
"doc/api/axes_api.rst:302:<autosummary>:1",
616614
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.update_datalim:2",
617615
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.update_datalim:2"
618616
],
619617
"Axes.datalim": [
620-
"doc/api/axes_api.rst:297:<autosummary>:1",
618+
"doc/api/axes_api.rst:302:<autosummary>:1",
621619
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.update_datalim_bounds:2"
622620
],
623621
"Axes.fmt_xdata": [
@@ -635,7 +633,7 @@
635633
"doc/api/prev_api_changes/api_changes_3.2.0/behavior.rst:96"
636634
],
637635
"AxesBase": [
638-
"doc/api/axes_api.rst:449:<autosummary>:1",
636+
"doc/api/axes_api.rst:454:<autosummary>:1",
639637
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.add_child_axes:2"
640638
],
641639
"Axis._update_ticks": [
@@ -663,10 +661,6 @@
663661
"doc/devel/MEP/MEP22.rst:60",
664662
"doc/devel/MEP/MEP23.rst:70"
665663
],
666-
"ClabelText": [
667-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.clabel:68",
668-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.clabel:68"
669-
],
670664
"ConnectionPatch": [
671665
"doc/users/prev_whats_new/whats_new_3.1.0.rst:178"
672666
],
@@ -741,10 +735,10 @@
741735
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.hexbin:71"
742736
],
743737
"QuadContourSet.changed()": [
744-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contour:130",
745-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contourf:130",
746-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contour:130",
747-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:130"
738+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contour:132",
739+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contourf:132",
740+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contour:132",
741+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:132"
748742
],
749743
"Quit": [
750744
"doc/devel/MEP/MEP22.rst:78"
@@ -829,6 +823,9 @@
829823
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.indicate_inset:19",
830824
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.inset_axes:11"
831825
],
826+
"axes": [
827+
"lib/matplotlib/axis.py:docstring of matplotlib.axis.Axis:23"
828+
],
832829
"axes.Axes.patch": [
833830
"doc/api/prev_api_changes/api_changes_1.3.x.rst:36"
834831
],
@@ -979,6 +976,7 @@
979976
"doc/devel/MEP/MEP23.rst:68"
980977
],
981978
"get_contains": [
979+
"lib/matplotlib/artist.py:docstring of matplotlib.axis.Axis.contains:29",
982980
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend.contains:29",
983981
"lib/matplotlib/offsetbox.py:docstring of matplotlib.offsetbox.AnnotationBbox.contains:29",
984982
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.QuiverKey.contains:29",
@@ -1003,15 +1001,8 @@
10031001
"h_pad": [
10041002
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure.set_constrained_layout:5"
10051003
],
1006-
"handler_map": [
1007-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.legend:242",
1008-
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure.legend:206",
1009-
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:201",
1010-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:206",
1011-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:242"
1012-
],
10131004
"image": [
1014-
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:72"
1005+
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:73"
10151006
],
10161007
"images": [
10171008
"lib/matplotlib/image.py:docstring of matplotlib.image.composite_images:2"
@@ -1504,10 +1495,11 @@
15041495
"doc/users/prev_whats_new/whats_new_3.1.0.rst:135"
15051496
],
15061497
"plot": [
1498+
"doc/tutorials/introductory/customizing.rst:193",
15071499
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:4"
15081500
],
15091501
"plot_include_source": [
1510-
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:51"
1502+
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:52"
15111503
],
15121504
"print_xyz": [
15131505
"lib/matplotlib/backends/backend_template.py:docstring of matplotlib.backends.backend_template:22"
@@ -1538,6 +1530,7 @@
15381530
"doc/devel/MEP/MEP23.rst:66"
15391531
],
15401532
"set_contains": [
1533+
"lib/matplotlib/artist.py:docstring of matplotlib.axis.Axis.contains:29",
15411534
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend.contains:29",
15421535
"lib/matplotlib/offsetbox.py:docstring of matplotlib.offsetbox.AnnotationBbox.contains:29",
15431536
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.QuiverKey.contains:29",

doc/users/prev_whats_new/whats_new_1.5.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,12 @@ which allow artist-level control of LaTeX rendering vs. the internal mathtex
509509
rendering.
510510

511511

512-
`.Axes.remove()` works as expected
513-
``````````````````````````````````
512+
``Axes.remove()`` works as expected
513+
```````````````````````````````````
514514

515515
As with artists added to an :class:`~matplotlib.axes.Axes`,
516516
`~.axes.Axes` objects can be removed from their figure via
517-
:meth:`~matplotlib.axes.Axes.remove()`.
517+
`~.Artist.remove()`.
518518

519519

520520
API Consistency fix within Locators set_params() function

examples/pyplots/align_ylabels.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def make_plot(axs):
5555
#
5656
#
5757
# Or we can manually align the axis labels between subplots manually using the
58-
# `~.YAxis.set_label_coords` method of the y-axis object. Note this requires
58+
# `~.Axis.set_label_coords` method of the y-axis object. Note this requires
5959
# we know a good offset value which is hardcoded.
6060

6161
fig, axs = plt.subplots(2, 2)

lib/matplotlib/artist.py

+35-36
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ def _default_contains(self, mouseevent, figure=None):
396396
return inside, info
397397
# subclass-specific implementation follows
398398
399-
The `canvas` kwarg is provided for the implementation of
400-
`Figure.contains`.
399+
The *canvas* kwarg is provided for the implementation of
400+
`.Figure.contains`.
401401
"""
402402
if callable(self._contains):
403403
return self._contains(self, mouseevent)
@@ -1298,24 +1298,6 @@ def get_valid_values(self, attr):
12981298

12991299
return 'unknown'
13001300

1301-
def _get_setters_and_targets(self):
1302-
"""
1303-
Get the attribute strings and a full path to where the setter
1304-
is defined for all setters in an object.
1305-
"""
1306-
setters = []
1307-
for name in dir(self.o):
1308-
if not name.startswith('set_'):
1309-
continue
1310-
func = getattr(self.o, name)
1311-
if (not callable(func)
1312-
or len(inspect.signature(func).parameters) < 2
1313-
or self.is_alias(func)):
1314-
continue
1315-
setters.append(
1316-
(name[4:], f"{func.__module__}.{func.__qualname__}"))
1317-
return setters
1318-
13191301
def _replace_path(self, source_class):
13201302
"""
13211303
Changes the full path to the public API path that is used
@@ -1332,7 +1314,17 @@ def get_setters(self):
13321314
Get the attribute strings with setters for object. e.g., for a line,
13331315
return ``['markerfacecolor', 'linewidth', ....]``.
13341316
"""
1335-
return [prop for prop, target in self._get_setters_and_targets()]
1317+
setters = []
1318+
for name in dir(self.o):
1319+
if not name.startswith('set_'):
1320+
continue
1321+
func = getattr(self.o, name)
1322+
if (not callable(func)
1323+
or len(inspect.signature(func).parameters) < 2
1324+
or self.is_alias(func)):
1325+
continue
1326+
setters.append(name[4:])
1327+
return setters
13361328

13371329
def is_alias(self, o):
13381330
"""Return whether method object *o* is an alias for another method."""
@@ -1381,24 +1373,20 @@ def pprint_setters(self, prop=None, leadingspace=2):
13811373
accepts = self.get_valid_values(prop)
13821374
return '%s%s: %s' % (pad, prop, accepts)
13831375

1384-
attrs = self._get_setters_and_targets()
1385-
attrs.sort()
13861376
lines = []
1387-
1388-
for prop, path in attrs:
1377+
for prop in sorted(self.get_setters()):
13891378
accepts = self.get_valid_values(prop)
13901379
name = self.aliased_name(prop)
1391-
13921380
lines.append('%s%s: %s' % (pad, name, accepts))
13931381
return lines
13941382

13951383
def pprint_setters_rest(self, prop=None, leadingspace=4):
13961384
"""
1397-
If *prop* is *None*, return a list of strings of all settable
1398-
properties and their valid values. Format the output for ReST
1385+
If *prop* is *None*, return a list of ReST-formatted strings of all
1386+
settable properties and their valid values.
13991387
14001388
If *prop* is not *None*, it is a valid property name and that
1401-
property will be returned as a string of property : valid
1389+
property will be returned as a string of "property : valid"
14021390
values.
14031391
"""
14041392
if leadingspace:
@@ -1409,13 +1397,24 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
14091397
accepts = self.get_valid_values(prop)
14101398
return '%s%s: %s' % (pad, prop, accepts)
14111399

1412-
attrs = sorted(self._get_setters_and_targets())
1413-
1414-
names = [self.aliased_name_rest(prop, target).replace(
1415-
'_base._AxesBase', 'Axes').replace(
1416-
'_axes.Axes', 'Axes')
1417-
for prop, target in attrs]
1418-
accepts = [self.get_valid_values(prop) for prop, target in attrs]
1400+
prop_and_qualnames = []
1401+
for prop in sorted(self.get_setters()):
1402+
# Find the parent method which actually provides the docstring.
1403+
for cls in self.o.__mro__:
1404+
method = getattr(cls, f"set_{prop}", None)
1405+
if method and method.__doc__ is not None:
1406+
break
1407+
else: # No docstring available.
1408+
method = getattr(self.o, f"set_{prop}")
1409+
prop_and_qualnames.append(
1410+
(prop, f"{method.__module__}.{method.__qualname__}"))
1411+
1412+
names = [self.aliased_name_rest(prop, target)
1413+
.replace('_base._AxesBase', 'Axes')
1414+
.replace('_axes.Axes', 'Axes')
1415+
for prop, target in prop_and_qualnames]
1416+
accepts = [self.get_valid_values(prop)
1417+
for prop, _ in prop_and_qualnames]
14191418

14201419
col0_len = max(len(n) for n in names)
14211420
col1_len = max(len(a) for a in accepts)

lib/matplotlib/axes/_base.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,7 @@ def _init_axis(self):
569569
self._update_transScale()
570570

571571
def set_figure(self, fig):
572-
"""
573-
Set the `.Figure` for this `.Axes`.
574-
575-
Parameters
576-
----------
577-
fig : `.Figure`
578-
"""
572+
# docstring inherited
579573
martist.Artist.set_figure(self, fig)
580574

581575
self.bbox = mtransforms.TransformedBbox(self._position,
@@ -2837,7 +2831,7 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
28372831
grid is determined by the zorder of each axis, not by the zorder of the
28382832
`.Line2D` objects comprising the grid. Therefore, to set grid zorder,
28392833
use `.set_axisbelow` or, for more control, call the
2840-
`~matplotlib.axis.Axis.set_zorder` method of each axis.
2834+
`~.Artist.set_zorder` method of each axis.
28412835
"""
28422836
if len(kwargs):
28432837
b = True

tutorials/introductory/lifecycle.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157

158158
###############################################################################
159159
# Next, we'll add labels to the plot. To do this with the OO interface,
160-
# we can use the :meth:`axes.Axes.set` method to set properties of this
161-
# Axes object.
160+
# we can use the `.Artist.set` method to set properties of this Axes object.
162161

163162
fig, ax = plt.subplots()
164163
ax.barh(group_names, group_data)

0 commit comments

Comments
 (0)