Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7900ee4

Browse files
committed
Merge pull request #4899 from sargas/remove-kwdocd-in-devel-doc
DOC: Replace kwdocd in docs with docstring.interpd/dedent_interpd
2 parents 8a2aab2 + 3ffbb23 commit 7900ee4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,23 @@ function that takes a ``**kwargs``. The requirements are:
8686
2. as automated as possible so that as properties change, the docs
8787
are updated automagically.
8888

89-
The functions :attr:`matplotlib.artist.kwdocd` and
90-
:func:`matplotlib.artist.kwdoc` to facilitate this. They combine
89+
The function :func:`matplotlib.artist.kwdoc` and the decorator
90+
:func:`matplotlib.docstring.dedent_interpd` facilitate this. They combine
9191
python string interpolation in the docstring with the matplotlib
9292
artist introspection facility that underlies ``setp`` and ``getp``.
93-
The ``kwdocd`` is a single dictionary that maps class name to a
94-
docstring of ``kwargs``. Here is an example from
93+
The ``kwdoc`` function gives the list of properties as a docstring. In order
94+
to use this in another docstring, first update the
95+
``matplotlib.docstring.interpd`` object, as seen in this example from
9596
:mod:`matplotlib.lines`::
9697

9798
# in lines.py
98-
artist.kwdocd['Line2D'] = artist.kwdoc(Line2D)
99+
docstring.interpd.update(Line2D=artist.kwdoc(Line2D))
99100

100101
Then in any function accepting :class:`~matplotlib.lines.Line2D`
101102
pass-through ``kwargs``, e.g., :meth:`matplotlib.axes.Axes.plot`::
102103

103104
# in axes.py
105+
@docstring.dedent_interpd
104106
def plot(self, *args, **kwargs):
105107
"""
106108
Some stuff omitted
@@ -114,7 +116,6 @@ pass-through ``kwargs``, e.g., :meth:`matplotlib.axes.Axes.plot`::
114116
information
115117
"""
116118
pass
117-
plot.__doc__ = cbook.dedent(plot.__doc__) % artist.kwdocd
118119

119120
Note there is a problem for :class:`~matplotlib.artist.Artist`
120121
``__init__`` methods, e.g., :meth:`matplotlib.patches.Patch.__init__`,
@@ -123,7 +124,7 @@ work until the class is fully defined and we can't modify the
123124
``Patch.__init__.__doc__`` docstring outside the class definition.
124125
There are some some manual hacks in this case, violating the
125126
"single entry point" requirement above -- see the
126-
``artist.kwdocd['Patch']`` setting in :mod:`matplotlib.patches`.
127+
``docstring.interpd.update`` calls in :mod:`matplotlib.patches`.
127128

128129
.. _formatting-mpl-docs:
129130

0 commit comments

Comments
 (0)