@@ -393,8 +393,8 @@ def _default_contains(self, mouseevent, figure=None):
393
393
return inside, info
394
394
# subclass-specific implementation follows
395
395
396
- The ` canvas` kwarg is provided for the implementation of
397
- `Figure.contains`.
396
+ The * canvas* kwarg is provided for the implementation of
397
+ `. Figure.contains`.
398
398
"""
399
399
if callable (self ._contains ):
400
400
return self ._contains (self , mouseevent )
@@ -1293,24 +1293,6 @@ def get_valid_values(self, attr):
1293
1293
1294
1294
return 'unknown'
1295
1295
1296
- def _get_setters_and_targets (self ):
1297
- """
1298
- Get the attribute strings and a full path to where the setter
1299
- is defined for all setters in an object.
1300
- """
1301
- setters = []
1302
- for name in dir (self .o ):
1303
- if not name .startswith ('set_' ):
1304
- continue
1305
- func = getattr (self .o , name )
1306
- if (not callable (func )
1307
- or len (inspect .signature (func ).parameters ) < 2
1308
- or self .is_alias (func )):
1309
- continue
1310
- setters .append (
1311
- (name [4 :], f"{ func .__module__ } .{ func .__qualname__ } " ))
1312
- return setters
1313
-
1314
1296
def _replace_path (self , source_class ):
1315
1297
"""
1316
1298
Changes the full path to the public API path that is used
@@ -1327,7 +1309,17 @@ def get_setters(self):
1327
1309
Get the attribute strings with setters for object. e.g., for a line,
1328
1310
return ``['markerfacecolor', 'linewidth', ....]``.
1329
1311
"""
1330
- return [prop for prop , target in self ._get_setters_and_targets ()]
1312
+ setters = []
1313
+ for name in dir (self .o ):
1314
+ if not name .startswith ('set_' ):
1315
+ continue
1316
+ func = getattr (self .o , name )
1317
+ if (not callable (func )
1318
+ or len (inspect .signature (func ).parameters ) < 2
1319
+ or self .is_alias (func )):
1320
+ continue
1321
+ setters .append (name [4 :])
1322
+ return setters
1331
1323
1332
1324
def is_alias (self , o ):
1333
1325
"""Return whether method object *o* is an alias for another method."""
@@ -1376,24 +1368,20 @@ def pprint_setters(self, prop=None, leadingspace=2):
1376
1368
accepts = self .get_valid_values (prop )
1377
1369
return '%s%s: %s' % (pad , prop , accepts )
1378
1370
1379
- attrs = self ._get_setters_and_targets ()
1380
- attrs .sort ()
1381
1371
lines = []
1382
-
1383
- for prop , path in attrs :
1372
+ for prop in sorted (self .get_setters ()):
1384
1373
accepts = self .get_valid_values (prop )
1385
1374
name = self .aliased_name (prop )
1386
-
1387
1375
lines .append ('%s%s: %s' % (pad , name , accepts ))
1388
1376
return lines
1389
1377
1390
1378
def pprint_setters_rest (self , prop = None , leadingspace = 4 ):
1391
1379
"""
1392
- If *prop* is *None*, return a list of strings of all settable
1393
- properties and their valid values. Format the output for ReST
1380
+ If *prop* is *None*, return a list of ReST-formatted strings of all
1381
+ settable properties and their valid values.
1394
1382
1395
1383
If *prop* is not *None*, it is a valid property name and that
1396
- property will be returned as a string of property : valid
1384
+ property will be returned as a string of " property : valid"
1397
1385
values.
1398
1386
"""
1399
1387
if leadingspace :
@@ -1404,13 +1392,24 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
1404
1392
accepts = self .get_valid_values (prop )
1405
1393
return '%s%s: %s' % (pad , prop , accepts )
1406
1394
1407
- attrs = sorted (self ._get_setters_and_targets ())
1408
-
1409
- names = [self .aliased_name_rest (prop , target ).replace (
1410
- '_base._AxesBase' , 'Axes' ).replace (
1411
- '_axes.Axes' , 'Axes' )
1412
- for prop , target in attrs ]
1413
- accepts = [self .get_valid_values (prop ) for prop , target in attrs ]
1395
+ prop_and_qualnames = []
1396
+ for prop in sorted (self .get_setters ()):
1397
+ # Find the parent method which actually provides the docstring.
1398
+ for cls in self .o .__mro__ :
1399
+ method = getattr (cls , f"set_{ prop } " , None )
1400
+ if method and method .__doc__ is not None :
1401
+ break
1402
+ else : # No docstring available.
1403
+ method = getattr (self .o , f"set_{ prop } " )
1404
+ prop_and_qualnames .append (
1405
+ (prop , f"{ method .__module__ } .{ method .__qualname__ } " ))
1406
+
1407
+ names = [self .aliased_name_rest (prop , target )
1408
+ .replace ('_base._AxesBase' , 'Axes' )
1409
+ .replace ('_axes.Axes' , 'Axes' )
1410
+ for prop , target in prop_and_qualnames ]
1411
+ accepts = [self .get_valid_values (prop )
1412
+ for prop , _ in prop_and_qualnames ]
1414
1413
1415
1414
col0_len = max (len (n ) for n in names )
1416
1415
col1_len = max (len (a ) for a in accepts )
0 commit comments