@@ -1545,6 +1545,41 @@ def _replacer(data, key):
1545
1545
"""
1546
1546
1547
1547
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
+
1548
1583
def _preprocess_data (replace_names = None , replace_all_args = False ,
1549
1584
label_namer = None , positional_parameter_names = None ):
1550
1585
"""
@@ -1789,27 +1824,15 @@ def inner(ax, *args, **kwargs):
1789
1824
"the Matplotlib list!)" % (label_namer , func .__name__ ),
1790
1825
RuntimeWarning , stacklevel = 2 )
1791
1826
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 )
1808
1830
if not python_has_wrapped :
1809
1831
inner .__wrapped__ = func
1810
1832
if new_sig is not None :
1811
1833
inner .__signature__ = new_sig
1812
1834
return inner
1835
+
1813
1836
return param
1814
1837
1815
1838
_log .info ('matplotlib version %s' , __version__ )
0 commit comments