@@ -5,7 +5,7 @@ Writing documentation
5
5
=====================
6
6
7
7
.. contents :: Contents
8
- :depth: 2
8
+ :depth: 3
9
9
:local:
10
10
:backlinks: top
11
11
:class: multicol-toc
@@ -387,123 +387,130 @@ and the Sphinx_ documentation. Some Matplotlib-specific formatting conventions
387
387
to keep in mind:
388
388
389
389
Function arguments
390
- Function arguments and keywords within docstrings should be referred to
391
- using the ``*emphasis* `` role. This will keep Matplotlib's documentation
392
- consistent with Python's documentation:
390
+ ~~~~~~~~~~~~~~~~~~
391
+ Function arguments and keywords within docstrings should be referred to
392
+ using the ``*emphasis* `` role. This will keep Matplotlib's documentation
393
+ consistent with Python's documentation:
393
394
394
- .. code-block :: rst
395
+ .. code-block :: rst
395
396
396
- If *linestyles* is *None*, the 'solid' is used.
397
+ If *linestyles* is *None*, the 'solid' is used.
397
398
398
- Do not use the ```default role` `` or the ````literal`` `` role:
399
+ Do not use the ```default role` `` or the ````literal`` `` role:
399
400
400
- .. code-block :: rst
401
+ .. code-block :: rst
401
402
402
- Neither `argument` nor ``argument`` should be used.
403
+ Neither `argument` nor ``argument`` should be used.
403
404
404
405
405
406
Quotes for strings
406
- Matplotlib does not have a convention whether to use single-quotes or
407
- double-quotes. There is a mixture of both in the current code.
407
+ ~~~~~~~~~~~~~~~~~~
408
+ Matplotlib does not have a convention whether to use single-quotes or
409
+ double-quotes. There is a mixture of both in the current code.
408
410
409
- Use simple single or double quotes when giving string values, e.g.:: rst
411
+ Use simple single or double quotes when giving string values, e.g.:: rst
410
412
411
- .. code-block :: rst
413
+ .. code-block :: rst
412
414
413
- If 'tight', try to figure out the tight bbox of the figure.
415
+ If 'tight', try to figure out the tight bbox of the figure.
414
416
415
417
Parameter type descriptions
416
- The main goal for parameter type descriptions is to be readable and
417
- understandable by humans. If the possible types are too complex use a
418
- simplification for the type description and explain the type more
419
- precisely in the text.
418
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
419
+ The main goal for parameter type descriptions is to be readable and
420
+ understandable by humans. If the possible types are too complex use a
421
+ simplification for the type description and explain the type more
422
+ precisely in the text.
420
423
421
- Generally, the `numpydoc docstring guide `_ conventions apply. The following
422
- rules expand on them where the numpydoc conventions are not specific.
424
+ Generally, the `numpydoc docstring guide `_ conventions apply. The following
425
+ rules expand on them where the numpydoc conventions are not specific.
423
426
424
- Use ``float `` for a type that can be any number.
427
+ Use ``float `` for a type that can be any number.
425
428
426
- Use ``array-like `` for homogeneous numeric sequences, which could
427
- typically be a numpy.array. Dimensionality may be specified using ``2D ``,
428
- ``3D ``, ``n-dimensional ``. If you need to have variables denoting the
429
- sizes of the dimensions, use capital letters in brackets
430
- (``array-like (M, N) ``). When refering to them in the text they are easier
431
- read and no special formatting is needed.
429
+ Use ``array-like `` for homogeneous numeric sequences, which could
430
+ typically be a numpy.array. Dimensionality may be specified using ``2D ``,
431
+ ``3D ``, ``n-dimensional ``. If you need to have variables denoting the
432
+ sizes of the dimensions, use capital letters in brackets
433
+ (``array-like (M, N) ``). When refering to them in the text they are easier
434
+ read and no special formatting is needed.
432
435
433
- ``float `` is the implicit default dtype for array-likes. For other dtypes
434
- use ``array-like of int ``.
436
+ ``float `` is the implicit default dtype for array-likes. For other dtypes
437
+ use ``array-like of int ``.
435
438
436
- Some possible uses::
439
+ Some possible uses::
437
440
438
- 2D array-like
439
- array-like (N)
440
- array-like (M, N)
441
- array-like (M, N, 3)
442
- array-like of int
441
+ 2D array-like
442
+ array-like (N)
443
+ array-like (M, N)
444
+ array-like (M, N, 3)
445
+ array-like of int
443
446
444
- Non-numeric homogeneous sequences are described as lists, e.g.::
447
+ Non-numeric homogeneous sequences are described as lists, e.g.::
445
448
446
- list of str
447
- list of `.Artist`
449
+ list of str
450
+ list of `.Artist`
448
451
449
452
Referencing types
450
- Generally, the rules from referring-to-other-code _ apply. More specifically:
453
+ ~~~~~~~~~~~~~~~~~
454
+ Generally, the rules from referring-to-other-code _ apply. More specifically:
451
455
452
- Use full references ```~matplotlib.colors.Normalize` `` with an
453
- abbreviation tilde in parameter types. While the full name helps the
454
- reader of plain text docstrings, the HTML does not need to show the full
455
- name as it links to it. Hence, the ``~ ``-shortening keeps it more readable.
456
+ Use full references ```~matplotlib.colors.Normalize` `` with an
457
+ abbreviation tilde in parameter types. While the full name helps the
458
+ reader of plain text docstrings, the HTML does not need to show the full
459
+ name as it links to it. Hence, the ``~ ``-shortening keeps it more readable.
456
460
457
- Use abbreviated links ```.Normalize` `` in the text.
461
+ Use abbreviated links ```.Normalize` `` in the text.
458
462
459
- .. code-block :: rst
463
+ .. code-block :: rst
460
464
461
- norm : `~matplotlib.colors.Normalize`, optional
462
- A `.Normalize` instance is used to scale luminance data to 0, 1.
465
+ norm : `~matplotlib.colors.Normalize`, optional
466
+ A `.Normalize` instance is used to scale luminance data to 0, 1.
463
467
464
468
``See also `` sections
465
- Sphinx automatically links code elements in the definition blocks of ``See
466
- also `` sections. No need to use backticks there::
469
+ ~~~~~~~~~~~~~~~~~~~~~
470
+ Sphinx automatically links code elements in the definition blocks of ``See
471
+ also `` sections. No need to use backticks there::
467
472
468
- See also
469
- --------
470
- vlines : vertical lines
471
- axhline: horizontal line across the axes
473
+ See also
474
+ --------
475
+ vlines : vertical lines
476
+ axhline: horizontal line across the axes
472
477
473
478
Wrapping parameter lists
474
- Long parameter lists should be wrapped using a ``\ `` for continuation and
475
- starting on the new line without any indent:
479
+ ~~~~~~~~~~~~~~~~~~~~~~~~
480
+ Long parameter lists should be wrapped using a ``\ `` for continuation and
481
+ starting on the new line without any indent:
476
482
477
- .. code-block :: python
483
+ .. code-block :: python
478
484
479
- def add_axes (self , * args , ** kwargs ):
480
- """
481
- ...
485
+ def add_axes (self , * args , ** kwargs ):
486
+ """
487
+ ...
482
488
483
- Parameters
484
- ----------
485
- projection :
486
- {'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', \
487
- 'rectilinear'}, optional
488
- The projection type of the axes.
489
+ Parameters
490
+ ----------
491
+ projection :
492
+ {'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', \
493
+ 'rectilinear'}, optional
494
+ The projection type of the axes.
489
495
490
- ...
491
- """
496
+ ...
497
+ """
492
498
493
- Alternatively, you can describe the valid parameter values in a dedicated
494
- section of the docstring.
499
+ Alternatively, you can describe the valid parameter values in a dedicated
500
+ section of the docstring.
495
501
496
502
rcParams
497
- rcParams can be referenced with the custom ``:rc: `` role:
498
- :literal: `:rc:\` foo\` ` yields ``rcParams["foo"] ``. Use `= [default-val] `
499
- to indicate the default value of the parameter. The default value should be
500
- literal, i.e. enclosed in double backticks. For simplicity these may be
501
- omitted for string default values.
503
+ ~~~~~~~~
504
+ rcParams can be referenced with the custom ``:rc: `` role:
505
+ :literal: `:rc:\` foo\` ` yields ``rcParams["foo"] ``. Use `= [default-val] `
506
+ to indicate the default value of the parameter. The default value should be
507
+ literal, i.e. enclosed in double backticks. For simplicity these may be
508
+ omitted for string default values.
502
509
503
- .. code-block :: rst
510
+ .. code-block :: rst
504
511
505
- If not provided, defaults to :rc:`figure.figsize` = ``[6.4, 4.8]``.
506
- If not provided, defaults to :rc:`figure.facecolor` = 'w'.
512
+ If not provided, defaults to :rc:`figure.figsize` = ``[6.4, 4.8]``.
513
+ If not provided, defaults to :rc:`figure.facecolor` = 'w'.
507
514
508
515
Deprecated formatting conventions
509
516
---------------------------------
0 commit comments