Skip to content

Commit 93a0058

Browse files
committed
changed paths in kwdocs
1 parent bfa8d61 commit 93a0058

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

lib/matplotlib/artist.py

+37-4
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ def mouseover(self, val):
10531053

10541054
class ArtistInspector(object):
10551055
"""
1056-
A helper class to inspect an :class:`~matplotlib.artist.Artist` and return
1056+
A helper class to inspect an `~matplotlib.artist.Artist` and return
10571057
information about its settable properties and their current values.
10581058
"""
10591059

@@ -1164,9 +1164,23 @@ def _get_setters_and_targets(self):
11641164
if name in cls.__dict__:
11651165
source_class = cls.__module__ + "." + cls.__name__
11661166
break
1167+
source_class = self._replace_path(source_class)
11671168
setters.append((name[4:], source_class + "." + name))
11681169
return setters
11691170

1171+
def _replace_path(self, source_class):
1172+
"""
1173+
Changes the full path to the public API path that is used
1174+
in sphinx. This is needed for links to work.
1175+
"""
1176+
1177+
replace_dict = {'_base._AxesBase': 'Axes',
1178+
'_axes.Axes': 'Axes'}
1179+
1180+
for key, value in replace_dict.items():
1181+
source_class = source_class.replace(key, value)
1182+
return source_class
1183+
11701184
def get_setters(self):
11711185
"""
11721186
Get the attribute strings with setters for object. e.g., for a line,
@@ -1461,12 +1475,31 @@ def setp(obj, *args, **kwargs):
14611475
return list(cbook.flatten(ret))
14621476

14631477

1464-
def kwdoc(a):
1478+
def kwdoc(artist):
1479+
"""
1480+
Inspect an `~matplotlib.artist.Artist` class and return
1481+
information about its settable properties and their current values.
1482+
1483+
It use the class `.ArtistInspector`.
1484+
1485+
Parameters
1486+
----------
1487+
artist : `~matplotlib.artist.Artist` or an iterable of `Artist`\s
1488+
1489+
Returns
1490+
-------
1491+
string
1492+
Returns a string with a list or rst table with the settable properties
1493+
of the *artist*. The formating depends on the value of
1494+
:rc:`docstring.hardcopy`. False result in a list that is intended for
1495+
easy reading as a docstring and True result in a rst table intended
1496+
for rendering the documentation with sphinx.
1497+
"""
14651498
hardcopy = matplotlib.rcParams['docstring.hardcopy']
14661499
if hardcopy:
1467-
return '\n'.join(ArtistInspector(a).pprint_setters_rest(
1500+
return '\n'.join(ArtistInspector(artist).pprint_setters_rest(
14681501
leadingspace=4))
14691502
else:
1470-
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2))
1503+
return '\n'.join(ArtistInspector(artist).pprint_setters(leadingspace=2))
14711504

14721505
docstring.interpd.update(Artist=kwdoc(Artist))

0 commit comments

Comments
 (0)