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

Skip to content

Commit 3083a89

Browse files
committed
Document doc style for default values
1 parent 96152ad commit 3083a89

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,6 @@ precisely in the text.
426426
Generally, the `numpydoc docstring guide`_ conventions apply. The following
427427
rules expand on them where the numpydoc conventions are not specific.
428428

429-
As opposed to the numpydoc guide, parameters need not be marked as
430-
*optional* if they have a simple default. This removes unnecessary clutter.
431-
The optional aspect is already clear from the presence of a default value.
432-
More specifically
433-
434-
- use ``{name} : {type}, default: {val}`` when possible.
435-
- use ``{name} : {type}, optional`` and describe the default in the text if
436-
in cannot be explained sufficiently in the above way.
437-
438429
Use ``float`` for a type that can be any number.
439430

440431
Use ``(float, float)`` to describe a 2D position. The parentheses should be
@@ -476,8 +467,52 @@ Use abbreviated links ```.Normalize``` in the text.
476467

477468
.. code-block:: rst
478469
479-
norm : `~matplotlib.colors.Normalize`, optional
480-
A `.Normalize` instance is used to scale luminance data to 0, 1.
470+
norm : `~matplotlib.colors.Normalize`, optional
471+
A `.Normalize` instance is used to scale luminance data to 0, 1.
472+
473+
Default values
474+
~~~~~~~~~~~~~~
475+
As opposed to the numpydoc guide, parameters need not be marked as
476+
*optional* if they have a simple default. This removes unnecessary clutter.
477+
The optional aspect is already clear from the presence of a default value.
478+
More specifically
479+
480+
- use ``{name} : {type}, default: {val}`` when possible.
481+
- use ``{name} : {type}, optional`` and describe the default in the text if
482+
in cannot be explained sufficiently in the above way.
483+
484+
The default value should provide semantic information targeted at a human
485+
reader. In simple cases, it just restates the value in the function signature.
486+
If applicable, units should be added.
487+
488+
.. code-block:: rst
489+
490+
Prefer:
491+
interval : int, default: 1000ms
492+
over:
493+
interval : int, default: 1000
494+
495+
If *None* is only used as a sentinel value for "parameter not specified", do
496+
not document it as the default. Depending on the context, give the actual
497+
default, or just mark the parameter as optional if not specifying has no
498+
particular effect.
499+
500+
.. code-block:: rst
501+
502+
Prefer:
503+
dpi : int, default: :rc:`figure.dpi`
504+
over:
505+
dpi : int, default: None
506+
507+
Prefer:
508+
textprops : dict, optional
509+
Dictionary of keyword parameters to be passed to the
510+
`~matplotlib.text.Text` instance contained inside TextArea.
511+
over:
512+
textprops : dict, default: None
513+
Dictionary of keyword parameters to be passed to the
514+
`~matplotlib.text.Text` instance contained inside TextArea.
515+
481516
482517
``See also`` sections
483518
~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)