Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2654be

Browse files
committed
Workaround to prevent "reference target not found" errors in doc builds
This introduces a known blacklist of currently non-linkable items.
1 parent 00c92c2 commit d2654be

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

doc/api/axis_api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ XAxis Specific
181181
XAxis.get_text_heights
182182
XAxis.get_ticks_position
183183
XAxis.set_ticks_position
184+
XAxis.set_label_position
184185
XAxis.tick_bottom
185186
XAxis.tick_top
186187

@@ -197,6 +198,7 @@ YAxis Specific
197198
YAxis.get_ticks_position
198199
YAxis.set_offset_position
199200
YAxis.set_ticks_position
201+
YAxis.set_label_position
200202
YAxis.tick_left
201203
YAxis.tick_right
202204

@@ -264,4 +266,5 @@ specify a matching series of labels. Calling ``set_ticks`` makes a
264266
Tick.set_label1
265267
Tick.set_label2
266268
Tick.set_pad
269+
Tick.set_url
267270
Tick.update_position

lib/matplotlib/artist.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,46 @@ def aliased_name(self, s):
14441444
aliases = ''.join(' or %s' % x for x in sorted(self.aliasd.get(s, [])))
14451445
return s + aliases
14461446

1447+
_NOT_LINKABLE = {
1448+
# A set of property setter methods that are not available in our
1449+
# current docs. This is a workaround used to prevent trying to link
1450+
# these setters which would lead to "target reference not found"
1451+
# warnings during doc build.
1452+
'matplotlib.image._ImageBase.set_alpha',
1453+
'matplotlib.image._ImageBase.set_array',
1454+
'matplotlib.image._ImageBase.set_data',
1455+
'matplotlib.image._ImageBase.set_filternorm',
1456+
'matplotlib.image._ImageBase.set_filterrad',
1457+
'matplotlib.image._ImageBase.set_interpolation',
1458+
'matplotlib.image._ImageBase.set_resample',
1459+
'matplotlib.image._ImageBase.set_alpha',
1460+
'matplotlib.image._ImageBase.set_array',
1461+
'matplotlib.image._ImageBase.set_data',
1462+
'matplotlib.image._ImageBase.set_filternorm',
1463+
'matplotlib.image._ImageBase.set_filterrad',
1464+
'matplotlib.image._ImageBase.set_interpolation',
1465+
'matplotlib.image._ImageBase.set_resample',
1466+
'matplotlib.image._ImageBase.set_alpha',
1467+
'matplotlib.image._ImageBase.set_array',
1468+
'matplotlib.image._ImageBase.set_filternorm',
1469+
'matplotlib.image._ImageBase.set_filterrad',
1470+
'matplotlib.image._ImageBase.set_interpolation',
1471+
'matplotlib.image._ImageBase.set_resample',
1472+
'matplotlib.image._ImageBase.set_alpha',
1473+
'matplotlib.image._ImageBase.set_array',
1474+
'matplotlib.image._ImageBase.set_filternorm',
1475+
'matplotlib.image._ImageBase.set_filterrad',
1476+
'matplotlib.image._ImageBase.set_resample',
1477+
'matplotlib.image._ImageBase.set_alpha',
1478+
'matplotlib.image._ImageBase.set_array',
1479+
'matplotlib.image._ImageBase.set_filternorm',
1480+
'matplotlib.image._ImageBase.set_filterrad',
1481+
'matplotlib.image._ImageBase.set_interpolation',
1482+
'matplotlib.image._ImageBase.set_resample',
1483+
'matplotlib.text._AnnotationBase.set_annotation_clip',
1484+
'matplotlib.text._AnnotationBase.set_annotation_clip',
1485+
}
1486+
14471487
def aliased_name_rest(self, s, target):
14481488
"""
14491489
Return 'PROPNAME or alias' if *s* has an alias, else return 'PROPNAME',
@@ -1453,6 +1493,10 @@ def aliased_name_rest(self, s, target):
14531493
alias, return 'markerfacecolor or mfc' and for the transform
14541494
property, which does not, return 'transform'.
14551495
"""
1496+
# workaround to prevent "reference target not found"
1497+
if target in self._NOT_LINKABLE:
1498+
return f'``{s}``'
1499+
14561500
aliases = ''.join(' or %s' % x for x in sorted(self.aliasd.get(s, [])))
14571501
return ':meth:`%s <%s>`%s' % (s, target, aliases)
14581502

@@ -1506,6 +1550,8 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
15061550
break
15071551
else: # No docstring available.
15081552
method = getattr(self.o, f"set_{prop}")
1553+
if method.__qualname__.startswith('_'):
1554+
print(method.__qualname__)
15091555
prop_and_qualnames.append(
15101556
(prop, f"{method.__module__}.{method.__qualname__}"))
15111557

@@ -1713,7 +1759,7 @@ def kwdoc(artist):
17131759
"""
17141760
ai = ArtistInspector(artist)
17151761
return ('\n'.join(ai.pprint_setters_rest(leadingspace=4))
1716-
if mpl.rcParams['docstring.hardcopy'] else
1762+
if mpl.rcParams['docstring.hardcopy'] or True else
17171763
'Properties:\n' + '\n'.join(ai.pprint_setters(leadingspace=4)))
17181764

17191765
# We defer this to the end of them module, because it needs ArtistInspector

0 commit comments

Comments
 (0)