@@ -1035,7 +1035,7 @@ def mouseover(self, val):
1035
1035
1036
1036
class ArtistInspector (object ):
1037
1037
"""
1038
- A helper class to inspect an :class: `~matplotlib.artist.Artist` and return
1038
+ A helper class to inspect an `~matplotlib.artist.Artist` and return
1039
1039
information about its settable properties and their current values.
1040
1040
"""
1041
1041
@@ -1146,9 +1146,23 @@ def _get_setters_and_targets(self):
1146
1146
if name in cls .__dict__ :
1147
1147
source_class = cls .__module__ + "." + cls .__name__
1148
1148
break
1149
+ source_class = self ._replace_path (source_class )
1149
1150
setters .append ((name [4 :], source_class + "." + name ))
1150
1151
return setters
1151
1152
1153
+ def _replace_path (self , source_class ):
1154
+ """
1155
+ Changes the full path to the public API path that is used
1156
+ in sphinx. This is needed for links to work.
1157
+ """
1158
+
1159
+ replace_dict = {'_base._AxesBase' : 'Axes' ,
1160
+ '_axes.Axes' : 'Axes' }
1161
+
1162
+ for key , value in replace_dict .items ():
1163
+ source_class = source_class .replace (key , value )
1164
+ return source_class
1165
+
1152
1166
def get_setters (self ):
1153
1167
"""
1154
1168
Get the attribute strings with setters for object. e.g., for a line,
@@ -1443,12 +1457,32 @@ def setp(obj, *args, **kwargs):
1443
1457
return list (cbook .flatten (ret ))
1444
1458
1445
1459
1446
- def kwdoc (a ):
1460
+ def kwdoc (artist ):
1461
+ """
1462
+ Inspect an `~matplotlib.artist.Artist` class and return
1463
+ information about its settable properties and their current values.
1464
+
1465
+ It use the class `.ArtistInspector`.
1466
+
1467
+ Parameters
1468
+ ----------
1469
+ artist : `~matplotlib.artist.Artist` or an iterable of `Artist`\s
1470
+
1471
+ Returns
1472
+ -------
1473
+ string
1474
+ Returns a string with a list or rst table with the settable properties
1475
+ of the *artist*. The formating depends on the value of
1476
+ :rc:`docstring.hardcopy`. False result in a list that is intended for
1477
+ easy reading as a docstring and True result in a rst table intended
1478
+ for rendering the documentation with sphinx.
1479
+ """
1447
1480
hardcopy = matplotlib .rcParams ['docstring.hardcopy' ]
1448
1481
if hardcopy :
1449
- return '\n ' .join (ArtistInspector (a ).pprint_setters_rest (
1482
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters_rest (
1450
1483
leadingspace = 4 ))
1451
1484
else :
1452
- return '\n ' .join (ArtistInspector (a ).pprint_setters (leadingspace = 2 ))
1485
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters (
1486
+ leadingspace = 2 ))
1453
1487
1454
1488
docstring .interpd .update (Artist = kwdoc (Artist ))
0 commit comments