1
+ .. redirect-from :: /devel/documenting_mpl
2
+
1
3
.. _documenting-matplotlib :
2
4
3
- =====================
4
- Writing documentation
5
- =====================
5
+ ===================
6
+ Write documentation
7
+ ===================
6
8
7
9
Getting started
8
10
===============
@@ -39,8 +41,8 @@ contents of :file:`index.rst` of the subdirectory. See
39
41
(excepting :file: `doc/api/api_changes/ `). Sphinx _ regenerates
40
42
files in these directories when building documentation.
41
43
42
- Setting up the doc build
43
- ------------------------
44
+ Set up the build
45
+ ----------------
44
46
45
47
The documentation for Matplotlib is generated from reStructuredText (ReST _)
46
48
using the Sphinx _ documentation generation tool.
@@ -50,8 +52,8 @@ To build the documentation you will need to
50
52
particular the :ref: `additional dependencies <doc-dependencies >` required to
51
53
build the documentation.
52
54
53
- Building the docs
54
- -----------------
55
+ Build the docs
56
+ --------------
55
57
56
58
The documentation sources are found in the :file: `doc/ ` directory.
57
59
The configuration file for Sphinx is :file: `doc/conf.py `. It controls which
@@ -105,8 +107,8 @@ On Windows, set the options as environment variables, e.g.:
105
107
106
108
set SPHINXOPTS = & set O = -j4 -Dplot_formats=png:100 & make html
107
109
108
- Showing locally built docs
109
- --------------------------
110
+ Show locally built docs
111
+ -----------------------
110
112
111
113
The built docs are available in the folder :file: `build/html `. A shortcut
112
114
for opening them in your default browser is:
@@ -117,8 +119,8 @@ for opening them in your default browser is:
117
119
118
120
.. _writing-rest-pages :
119
121
120
- Writing ReST pages
121
- ==================
122
+ Write ReST pages
123
+ ================
122
124
123
125
Most documentation is either in the docstrings of individual
124
126
classes and methods, in explicit ``.rst `` files, or in examples and tutorials.
@@ -189,8 +191,8 @@ nor the ````literal```` role:
189
191
190
192
.. _internal-section-refs :
191
193
192
- Referring to other documents and sections
193
- -----------------------------------------
194
+ Refer to other documents and sections
195
+ -------------------------------------
194
196
195
197
Sphinx _ allows internal references _ between documents.
196
198
@@ -254,8 +256,8 @@ hyphens to separate words.
254
256
255
257
.. _referring-to-other-code :
256
258
257
- Referring to other code
258
- -----------------------
259
+ Refer to other code
260
+ -------------------
259
261
260
262
To link to other methods, classes, or modules in Matplotlib you can use
261
263
back ticks, for example:
@@ -313,8 +315,8 @@ commands::
313
315
314
316
.. _rst-figures-and-includes :
315
317
316
- Including figures and files
317
- ---------------------------
318
+ Include figures and files
319
+ -------------------------
318
320
319
321
Image files can directly included in pages with the ``image:: `` directive.
320
322
e.g., :file: `tutorials/intermediate/constrainedlayout_guide.py ` displays
@@ -353,8 +355,8 @@ expression in the Matplotlib figure. In these cases, you can use the
353
355
354
356
.. _writing-docstrings :
355
357
356
- Writing docstrings
357
- ==================
358
+ Write docstrings
359
+ ================
358
360
359
361
Most of the API documentation is written in docstrings. These are comment
360
362
blocks in source code that explain how the code works.
@@ -516,8 +518,8 @@ Non-numeric homogeneous sequences are described as lists, e.g.::
516
518
list of str
517
519
list of `.Artist`
518
520
519
- Referencing types
520
- ~~~~~~~~~~~~~~~~~
521
+ Reference types
522
+ ~~~~~~~~~~~~~~~
521
523
Generally, the rules from referring-to-other-code _ apply. More specifically:
522
524
523
525
Use full references ```~matplotlib.colors.Normalize` `` with an
@@ -584,8 +586,8 @@ also`` sections. No need to use backticks there::
584
586
vlines : vertical lines
585
587
axhline : horizontal line across the Axes
586
588
587
- Wrapping parameter lists
588
- ~~~~~~~~~~~~~~~~~~~~~~~~
589
+ Wrap parameter lists
590
+ ~~~~~~~~~~~~~~~~~~~~
589
591
Long parameter lists should be wrapped using a ``\ `` for continuation and
590
592
starting on the new line without any indent (no indent because pydoc will
591
593
parse the docstring and strip the line continuation so that indent would
@@ -744,8 +746,8 @@ point, `.kwdoc` can list the properties and interpolate them into
744
746
``__init__.__doc__ ``.
745
747
746
748
747
- Inheriting docstrings
748
- ---------------------
749
+ Inherit docstrings
750
+ ------------------
749
751
750
752
If a subclass overrides a method but does not change the semantics, we can
751
753
reuse the parent docstring for the method of the child class. Python does this
@@ -768,8 +770,8 @@ the future::
768
770
769
771
.. _docstring-adding-figures :
770
772
771
- Adding figures
772
- --------------
773
+ Add figures
774
+ -----------
773
775
774
776
As above (see :ref: `rst-figures-and-includes `), figures in the examples gallery
775
777
can be referenced with a ``.. plot:: `` directive pointing to the python script
@@ -813,8 +815,8 @@ code will also appear in interactive docstrings.
813
815
814
816
.. _writing-examples-and-tutorials :
815
817
816
- Writing examples and tutorials
817
- ==============================
818
+ Write examples and tutorials
819
+ ============================
818
820
819
821
Examples and tutorials are Python scripts that are run by `Sphinx Gallery `_.
820
822
Sphinx Gallery finds ``*.py `` files in source directories and runs the files to
@@ -841,8 +843,8 @@ these ``*.rst`` files from the source location to the build location (see
841
843
In the Python files, to exclude an example from having a plot generated, insert
842
844
"sgskip" somewhere in the filename.
843
845
844
- Formatting the example
845
- ----------------------
846
+ Format
847
+ ------
846
848
847
849
The format of these files is relatively straightforward. Properly
848
850
formatted comment blocks are treated as ReST _ text, the code is
@@ -913,8 +915,26 @@ ReST text are delimited by the line ``# %%`` :
913
915
914
916
In this way text, code, and figures are output in a "notebook" style.
915
917
916
- References for sphinx-gallery
917
- -----------------------------
918
+ .. _sample-data :
919
+
920
+ Data
921
+ ----
922
+
923
+ When sample data comes from a public dataset, please cite the source of the
924
+ data. Sample data should be written out in the code. When this is not
925
+ feasible, the data can be loaded using ~cbook.sample_data
926
+
927
+ .. code-block :: python
928
+
929
+ import matplotlib.cbook as cbook
930
+ fh = cbook.get_sample_data(' mydata.dat' )
931
+
932
+
933
+ If the data is too large to be included in the code, it should be added to
934
+ :file: `lib/matplotlib/mpl-data/sample_data/ `
935
+
936
+ Create mini-gallery
937
+ -------------------
918
938
919
939
The showcased Matplotlib functions should be listed in an admonition at the
920
940
bottom as follows
@@ -942,8 +962,9 @@ Functions that exist in ``pyplot`` as well as in Axes or Figure should mention
942
962
both references no matter which one is used in the example code. The ``pyplot ``
943
963
reference should always be the second to mention; see the example above.
944
964
945
- Order of examples in the gallery
946
- --------------------------------
965
+
966
+ Order examples
967
+ --------------
947
968
948
969
The order of the sections of the :ref: `tutorials ` and the :ref: `gallery `, as
949
970
well as the order of the examples within each section are determined in a
@@ -984,8 +1005,8 @@ manual ``index.rst``.
984
1005
Miscellaneous
985
1006
=============
986
1007
987
- Moving documentation
988
- --------------------
1008
+ Move documentation
1009
+ ------------------
989
1010
990
1011
Sometimes it is desirable to move or consolidate documentation. With no
991
1012
action this will lead to links either going dead (404) or pointing to old
@@ -1020,8 +1041,8 @@ For clarity, do not use relative links.
1020
1041
1021
1042
.. _inheritance-diagrams :
1022
1043
1023
- Generating inheritance diagrams
1024
- -------------------------------
1044
+ Generate inheritance diagrams
1045
+ -----------------------------
1025
1046
1026
1047
Class inheritance diagrams can be generated with the Sphinx
1027
1048
`inheritance-diagram `_ directive.
0 commit comments