@@ -396,8 +396,8 @@ def _default_contains(self, mouseevent, figure=None):
396396 return inside, info
397397 # subclass-specific implementation follows
398398
399- The *figure * kwarg is provided for the implementation of
400- `Figure.contains`.
399+ The *canvas * kwarg is provided for the implementation of
400+ `. Figure.contains`.
401401 """
402402 if callable (self ._contains ):
403403 return self ._contains (self , mouseevent )
@@ -1304,24 +1304,6 @@ def get_valid_values(self, attr):
13041304
13051305 return 'unknown'
13061306
1307- def _get_setters_and_targets (self ):
1308- """
1309- Get the attribute strings and a full path to where the setter
1310- is defined for all setters in an object.
1311- """
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 (
1322- (name [4 :], f"{ func .__module__ } .{ func .__qualname__ } " ))
1323- return setters
1324-
13251307 def _replace_path (self , source_class ):
13261308 """
13271309 Changes the full path to the public API path that is used
@@ -1338,7 +1320,17 @@ def get_setters(self):
13381320 Get the attribute strings with setters for object. e.g., for a line,
13391321 return ``['markerfacecolor', 'linewidth', ....]``.
13401322 """
1341- return [prop for prop , target in self ._get_setters_and_targets ()]
1323+ setters = []
1324+ for name in dir (self .o ):
1325+ if not name .startswith ('set_' ):
1326+ continue
1327+ func = getattr (self .o , name )
1328+ if (not callable (func )
1329+ or len (inspect .signature (func ).parameters ) < 2
1330+ or self .is_alias (func )):
1331+ continue
1332+ setters .append (name [4 :])
1333+ return setters
13421334
13431335 def is_alias (self , o ):
13441336 """Return whether method object *o* is an alias for another method."""
@@ -1387,24 +1379,20 @@ def pprint_setters(self, prop=None, leadingspace=2):
13871379 accepts = self .get_valid_values (prop )
13881380 return '%s%s: %s' % (pad , prop , accepts )
13891381
1390- attrs = self ._get_setters_and_targets ()
1391- attrs .sort ()
13921382 lines = []
1393-
1394- for prop , path in attrs :
1383+ for prop in sorted (self .get_setters ()):
13951384 accepts = self .get_valid_values (prop )
13961385 name = self .aliased_name (prop )
1397-
13981386 lines .append ('%s%s: %s' % (pad , name , accepts ))
13991387 return lines
14001388
14011389 def pprint_setters_rest (self , prop = None , leadingspace = 4 ):
14021390 """
1403- If *prop* is *None*, return a list of strings of all settable
1404- properties and their valid values. Format the output for ReST
1391+ If *prop* is *None*, return a list of ReST-formatted strings of all
1392+ settable properties and their valid values.
14051393
14061394 If *prop* is not *None*, it is a valid property name and that
1407- property will be returned as a string of property : valid
1395+ property will be returned as a string of " property : valid"
14081396 values.
14091397 """
14101398 if leadingspace :
@@ -1415,13 +1403,24 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
14151403 accepts = self .get_valid_values (prop )
14161404 return '%s%s: %s' % (pad , prop , accepts )
14171405
1418- attrs = sorted (self ._get_setters_and_targets ())
1419-
1420- names = [self .aliased_name_rest (prop , target ).replace (
1421- '_base._AxesBase' , 'Axes' ).replace (
1422- '_axes.Axes' , 'Axes' )
1423- for prop , target in attrs ]
1424- accepts = [self .get_valid_values (prop ) for prop , target in attrs ]
1406+ prop_and_qualnames = []
1407+ for prop in sorted (self .get_setters ()):
1408+ # Find the parent method which actually provides the docstring.
1409+ for cls in self .o .__mro__ :
1410+ method = getattr (cls , f"set_{ prop } " , None )
1411+ if method and method .__doc__ is not None :
1412+ break
1413+ else : # No docstring available.
1414+ method = getattr (self .o , f"set_{ prop } " )
1415+ prop_and_qualnames .append (
1416+ (prop , f"{ method .__module__ } .{ method .__qualname__ } " ))
1417+
1418+ names = [self .aliased_name_rest (prop , target )
1419+ .replace ('_base._AxesBase' , 'Axes' )
1420+ .replace ('_axes.Axes' , 'Axes' )
1421+ for prop , target in prop_and_qualnames ]
1422+ accepts = [self .get_valid_values (prop )
1423+ for prop , _ in prop_and_qualnames ]
14251424
14261425 col0_len = max (len (n ) for n in names )
14271426 col1_len = max (len (a ) for a in accepts )
0 commit comments