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

Skip to content

Commit a039e20

Browse files
committed
Make optional in docstrings optional
1 parent b03370a commit a039e20

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,19 +350,19 @@ An example docstring looks like:
350350
Respective beginning and end of each line. If scalars are
351351
provided, all lines will have the same length.
352352
353-
colors : array-like of colors, optional, default: 'k'
353+
colors : array-like of colors, default: 'k'
354354
355-
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional
355+
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid'
356356
357-
label : string, optional, default: ''
357+
label : str, default: ''
358358
359359
Returns
360360
-------
361361
lines : `~matplotlib.collections.LineCollection`
362362
363363
Other Parameters
364364
----------------
365-
**kwargs : `~matplotlib.collections.LineCollection` properties.
365+
**kwargs : `~matplotlib.collections.LineCollection` properties
366366
367367
See also
368368
--------
@@ -420,9 +420,17 @@ precisely in the text.
420420
Generally, the `numpydoc docstring guide`_ conventions apply. The following
421421
rules expand on them where the numpydoc conventions are not specific.
422422

423+
As opposed to the numpydoc guide, parameters need not be marked as
424+
*optional*. This removes unnecessary clutter. The optional aspect is already
425+
clear from the presence of a default parameter (visible in the signature or
426+
expicit in the docstring). *optional* may be scarcely used when this
427+
information is not available in the context of the docstring (e.g. when
428+
it's hidden behind ``*args`` or ``*kwargs``).
429+
423430
Use ``float`` for a type that can be any number.
424431

425-
Use ``(float, float)`` to describe a 2D position.
432+
Use ``(float, float)`` to describe a 2D position. The parentheses should be
433+
included to make the tuple-ness more obvious.
426434

427435
Use ``array-like`` for homogeneous numeric sequences, which could
428436
typically be a numpy.array. Dimensionality may be specified using ``2D``,
@@ -460,7 +468,7 @@ Use abbreviated links ```.Normalize``` in the text.
460468

461469
.. code-block:: rst
462470
463-
norm : `~matplotlib.colors.Normalize`, optional
471+
norm : `~matplotlib.colors.Normalize`
464472
A `.Normalize` instance is used to scale luminance data to 0, 1.
465473
466474
``See also`` sections
@@ -489,7 +497,7 @@ result in a lot of whitespace within the line):
489497
Parameters
490498
----------
491499
projection : {'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', \
492-
'rectilinear'}, optional
500+
'rectilinear'}
493501
The projection type of the axes.
494502
495503
...

0 commit comments

Comments
 (0)