Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2bd9efd

Browse filesBrowse files
committed
Deemphasize ACCEPTS blocks in documenting_mpl docs.
They are almost never needed and should only be used in rare cases.
1 parent 4616f70 commit 2bd9efd
Copy full SHA for 2bd9efd

File tree

Expand file treeCollapse file tree

1 file changed

+34
-23
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+34
-23
lines changed

‎doc/devel/documenting_mpl.rst

Copy file name to clipboardExpand all lines: doc/devel/documenting_mpl.rst
+34-23Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -562,44 +562,55 @@ By convention, these setters and getters are named ``set_PROPERTYNAME`` and
562562
``get_PROPERTYNAME``; the list of properties thusly defined on an artist and
563563
their values can be listed by the `~.pyplot.setp` and `~.pyplot.getp` functions.
564564

565-
.. note::
566-
567-
``ACCEPTS`` blocks have recently become optional. You may now use a
568-
numpydoc ``Parameters`` block because the accepted values can now be read
569-
from the type description of the first parameter.
570-
571-
Property setter methods should indicate the values they accept using a (legacy)
572-
special block in the docstring, starting with ``ACCEPTS``, as follows:
565+
The Parameters block of property setter methods is parsed to document the
566+
accepted values, e.g. the docstring of `.Line2D.set_linestyle` starts with
573567

574568
.. code-block:: python
575569
576-
# in lines.py
577-
def set_linestyle(self, linestyle):
570+
def set_linestyle(self, ls):
578571
"""
579-
Set the linestyle of the line
572+
Set the linestyle of the line.
580573
581-
ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ]
574+
Parameters
575+
----------
576+
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
577+
etc.
582578
"""
583579
584-
The ACCEPTS block is used to render a table of all properties and their
585-
acceptable values in the docs; it can also be displayed using, e.g.,
586-
``plt.setp(Line2D)`` (all properties) or ``plt.setp(Line2D, 'linestyle')``
587-
(just one property).
580+
which results in the following line in the output of ``plt.setp(line)`` or
581+
``plt.setp(line, "linestyle")``::
582+
583+
linestyle or ls: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
588584

589-
There are cases in which the ACCEPTS string is not useful in the
590-
generated Sphinx documentation, e.g. if the valid parameters are already
591-
defined in the numpydoc parameter list. You can hide the ACCEPTS string from
592-
Sphinx by making it a ReST comment (i.e. use ``.. ACCEPTS:``):
585+
In some rare cases (mostly, setters which accept both a single tuple and an
586+
unpacked tuple), the accepted values cannot be documented in such a fashion;
587+
in that case, they can be documented as an ``.. ACCEPTS:`` block, e.g. for
588+
`.axes.Axes.set_xlim`:
593589

594590
.. code-block:: python
595591
596-
def set_linestyle(self, linestyle):
592+
def set_xlim(self, ...):
597593
"""
598-
An ACCEPTS string invisible to Sphinx.
594+
Set the x-axis view limits.
595+
596+
Parameters
597+
----------
598+
left : float, optional
599+
The left xlim in data coordinates. Passing *None* leaves the
600+
limit unchanged.
601+
602+
The left and right xlims may also be passed as the tuple
603+
(*left*, *right*) as the first positional argument (or as
604+
the *left* keyword argument).
605+
606+
.. ACCEPTS: (bottom: float, top: float)
599607
600-
.. ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ]
608+
right : float, optional
609+
etc.
601610
"""
602611
612+
Note that the leading ``..`` makes the ``.. ACCEPTS:`` block a reST comment,
613+
hiding it from the rendered docs.
603614

604615
Keyword arguments
605616
-----------------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.