@@ -426,15 +426,6 @@ precisely in the text.
426
426
Generally, the `numpydoc docstring guide `_ conventions apply. The following
427
427
rules expand on them where the numpydoc conventions are not specific.
428
428
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
-
438
429
Use ``float `` for a type that can be any number.
439
430
440
431
Use ``(float, float) `` to describe a 2D position. The parentheses should be
@@ -476,8 +467,52 @@ Use abbreviated links ```.Normalize``` in the text.
476
467
477
468
.. code-block :: rst
478
469
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
+
481
516
482
517
``See also `` sections
483
518
~~~~~~~~~~~~~~~~~~~~~
0 commit comments