@@ -1545,6 +1545,41 @@ def _replacer(data, key):
15451545"""
15461546
15471547
1548+ def _add_data_doc (docstring , replace_names , replace_all_args ):
1549+ """Add documentation for a *data* field to the given docstring.
1550+
1551+ Parameters
1552+ ----------
1553+ docstring : str
1554+ The input docstring.
1555+ replace_names : list of strings or None
1556+ The list of parameter names which arguments should be replaced by
1557+ `data[name]`. If None, all arguments are replaced if they are
1558+ included in `data`.
1559+ replace_all_args : bool
1560+ If True, all arguments in *args get replaced, even if they are not
1561+ in replace_names.
1562+
1563+ Returns
1564+ -------
1565+ The augmented docstring.
1566+ """
1567+ if docstring is None :
1568+ docstring = ''
1569+ else :
1570+ docstring = dedent (docstring )
1571+ _repl = ""
1572+ if replace_names is None :
1573+ _repl = "* All positional and all keyword arguments."
1574+ else :
1575+ if len (replace_names ) != 0 :
1576+ _repl = "* All arguments with the following names: '{names}'."
1577+ if replace_all_args :
1578+ _repl += "\n * All positional arguments."
1579+ _repl = _repl .format (names = "', '" .join (sorted (replace_names )))
1580+ return docstring + _DATA_DOC_APPENDIX .format (replaced = _repl )
1581+
1582+
15481583def _preprocess_data (replace_names = None , replace_all_args = False ,
15491584 label_namer = None , positional_parameter_names = None ):
15501585 """
@@ -1789,27 +1824,15 @@ def inner(ax, *args, **kwargs):
17891824 "the Matplotlib list!)" % (label_namer , func .__name__ ),
17901825 RuntimeWarning , stacklevel = 2 )
17911826 return func (ax , * args , ** kwargs )
1792- pre_doc = inner .__doc__
1793- if pre_doc is None :
1794- pre_doc = ''
1795- else :
1796- pre_doc = dedent (pre_doc )
1797- _repl = ""
1798- if replace_names is None :
1799- _repl = "* All positional and all keyword arguments."
1800- else :
1801- if len (replace_names ) != 0 :
1802- _repl = "* All arguments with the following names: '{names}'."
1803- if replace_all_args :
1804- _repl += "\n * All positional arguments."
1805- _repl = _repl .format (names = "', '" .join (sorted (replace_names )))
1806- inner .__doc__ = (pre_doc +
1807- _DATA_DOC_APPENDIX .format (replaced = _repl ))
1827+
1828+ inner .__doc__ = _add_data_doc (inner .__doc__ ,
1829+ replace_names , replace_all_args )
18081830 if not python_has_wrapped :
18091831 inner .__wrapped__ = func
18101832 if new_sig is not None :
18111833 inner .__signature__ = new_sig
18121834 return inner
1835+
18131836 return param
18141837
18151838_log .info ('matplotlib version %s' , __version__ )
0 commit comments