MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / pprint_setters_rest

Method pprint_setters_rest

lib/matplotlib/artist.py:1700–1753  ·  view source on GitHub ↗

If *prop* is *None*, return a list of reST-formatted strings of all settable properties and their valid values. If *prop* is not *None*, it is a valid property name and that property will be returned as a string of "property : valid" values.

(self, prop=None, leadingspace=4)

Source from the content-addressed store, hash-verified

1698 return lines
1699
1700 def pprint_setters_rest(self, prop=None, leadingspace=4):
1701 """
1702 If *prop* is *None*, return a list of reST-formatted strings of all
1703 settable properties and their valid values.
1704
1705 If *prop* is not *None*, it is a valid property name and that
1706 property will be returned as a string of "property : valid"
1707 values.
1708 """
1709 if leadingspace:
1710 pad = ' ' * leadingspace
1711 else:
1712 pad = ''
1713 if prop is not None:
1714 accepts = self.get_valid_values(prop)
1715 return f'{pad}{prop}: {accepts}'
1716
1717 prop_and_qualnames = []
1718 for prop in sorted(self.get_setters()):
1719 # Find the parent method which actually provides the docstring.
1720 for cls in self.o.__mro__:
1721 method = getattr(cls, f"set_{prop}", None)
1722 if method and method.__doc__ is not None:
1723 break
1724 else: # No docstring available.
1725 method = getattr(self.o, f"set_{prop}")
1726 prop_and_qualnames.append(
1727 (prop, f"{method.__module__}.{method.__qualname__}"))
1728
1729 names = [self.aliased_name_rest(prop, target)
1730 .replace('_base._AxesBase', 'Axes')
1731 .replace('_axes.Axes', 'Axes')
1732 for prop, target in prop_and_qualnames]
1733 accepts = [self.get_valid_values(prop)
1734 for prop, _ in prop_and_qualnames]
1735
1736 col0_len = max(len(n) for n in names)
1737 col1_len = max(len(a) for a in accepts)
1738 table_formatstr = pad + ' ' + '=' * col0_len + ' ' + '=' * col1_len
1739
1740 return [
1741 '',
1742 pad + '.. table::',
1743 pad + ' :class: property-table',
1744 '',
1745 table_formatstr,
1746 pad + ' ' + 'Property'.ljust(col0_len)
1747 + ' ' + 'Description'.ljust(col1_len),
1748 table_formatstr,
1749 *[pad + ' ' + n.ljust(col0_len) + ' ' + a.ljust(col1_len)
1750 for n, a in zip(names, accepts)],
1751 table_formatstr,
1752 '',
1753 ]
1754
1755 def properties(self):
1756 """Return a dictionary mapping property name -> value."""

Callers 1

kwdocFunction · 0.95

Calls 3

get_valid_valuesMethod · 0.95
get_settersMethod · 0.95
aliased_name_restMethod · 0.95

Tested by

no test coverage detected