@@ -1053,7 +1053,7 @@ def mouseover(self, val):
1053
1053
1054
1054
class ArtistInspector (object ):
1055
1055
"""
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
1057
1057
information about its settable properties and their current values.
1058
1058
"""
1059
1059
@@ -1164,9 +1164,23 @@ def _get_setters_and_targets(self):
1164
1164
if name in cls .__dict__ :
1165
1165
source_class = cls .__module__ + "." + cls .__name__
1166
1166
break
1167
+ source_class = self ._replace_path (source_class )
1167
1168
setters .append ((name [4 :], source_class + "." + name ))
1168
1169
return setters
1169
1170
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
+
1170
1184
def get_setters (self ):
1171
1185
"""
1172
1186
Get the attribute strings with setters for object. e.g., for a line,
@@ -1461,12 +1475,31 @@ def setp(obj, *args, **kwargs):
1461
1475
return list (cbook .flatten (ret ))
1462
1476
1463
1477
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
+ """
1465
1498
hardcopy = matplotlib .rcParams ['docstring.hardcopy' ]
1466
1499
if hardcopy :
1467
- return '\n ' .join (ArtistInspector (a ).pprint_setters_rest (
1500
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters_rest (
1468
1501
leadingspace = 4 ))
1469
1502
else :
1470
- return '\n ' .join (ArtistInspector (a ).pprint_setters (leadingspace = 2 ))
1503
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters (leadingspace = 2 ))
1471
1504
1472
1505
docstring .interpd .update (Artist = kwdoc (Artist ))
0 commit comments