@@ -1087,7 +1087,7 @@ def mouseover(self, val):
1087
1087
1088
1088
class ArtistInspector (object ):
1089
1089
"""
1090
- A helper class to inspect an :class: `~matplotlib.artist.Artist` and return
1090
+ A helper class to inspect an `~matplotlib.artist.Artist` and return
1091
1091
information about its settable properties and their current values.
1092
1092
"""
1093
1093
@@ -1198,9 +1198,23 @@ def _get_setters_and_targets(self):
1198
1198
if name in cls .__dict__ :
1199
1199
source_class = cls .__module__ + "." + cls .__name__
1200
1200
break
1201
+ source_class = self ._replace_path (source_class )
1201
1202
setters .append ((name [4 :], source_class + "." + name ))
1202
1203
return setters
1203
1204
1205
+ def _replace_path (self , source_class ):
1206
+ """
1207
+ Changes the full path to the public API path that is used
1208
+ in sphinx. This is needed for links to work.
1209
+ """
1210
+
1211
+ replace_dict = {'_base._AxesBase' : 'Axes' ,
1212
+ '_axes.Axes' : 'Axes' }
1213
+
1214
+ for key , value in replace_dict .items ():
1215
+ source_class = source_class .replace (key , value )
1216
+ return source_class
1217
+
1204
1218
def get_setters (self ):
1205
1219
"""
1206
1220
Get the attribute strings with setters for object. e.g., for a line,
@@ -1495,12 +1509,32 @@ def setp(obj, *args, **kwargs):
1495
1509
return list (cbook .flatten (ret ))
1496
1510
1497
1511
1498
- def kwdoc (a ):
1512
+ def kwdoc (artist ):
1513
+ """
1514
+ Inspect an `~matplotlib.artist.Artist` class and return
1515
+ information about its settable properties and their current values.
1516
+
1517
+ It use the class `.ArtistInspector`.
1518
+
1519
+ Parameters
1520
+ ----------
1521
+ artist : `~matplotlib.artist.Artist` or an iterable of `Artist`\s
1522
+
1523
+ Returns
1524
+ -------
1525
+ string
1526
+ Returns a string with a list or rst table with the settable properties
1527
+ of the *artist*. The formating depends on the value of
1528
+ :rc:`docstring.hardcopy`. False result in a list that is intended for
1529
+ easy reading as a docstring and True result in a rst table intended
1530
+ for rendering the documentation with sphinx.
1531
+ """
1499
1532
hardcopy = matplotlib .rcParams ['docstring.hardcopy' ]
1500
1533
if hardcopy :
1501
- return '\n ' .join (ArtistInspector (a ).pprint_setters_rest (
1534
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters_rest (
1502
1535
leadingspace = 4 ))
1503
1536
else :
1504
- return '\n ' .join (ArtistInspector (a ).pprint_setters (leadingspace = 2 ))
1537
+ return '\n ' .join (ArtistInspector (artist ).pprint_setters (
1538
+ leadingspace = 2 ))
1505
1539
1506
1540
docstring .interpd .update (Artist = kwdoc (Artist ))
0 commit comments