1+ .. redirect-from :: /devel/documenting_mpl
2+
13.. _documenting-matplotlib :
24
3- =====================
4- Writing documentation
5- =====================
5+ ===================
6+ Write documentation
7+ ===================
68
79Getting started
810===============
@@ -39,8 +41,8 @@ contents of :file:`index.rst` of the subdirectory. See
3941 (excepting :file: `doc/api/api_changes/ `). Sphinx _ regenerates
4042 files in these directories when building documentation.
4143
42- Setting up the doc build
43- ------------------------
44+ Set up the build
45+ ----------------
4446
4547The documentation for Matplotlib is generated from reStructuredText (ReST _)
4648using the Sphinx _ documentation generation tool.
@@ -50,8 +52,8 @@ To build the documentation you will need to
5052particular the :ref: `additional dependencies <doc-dependencies >` required to
5153build the documentation.
5254
53- Building the docs
54- -----------------
55+ Build the docs
56+ --------------
5557
5658The documentation sources are found in the :file: `doc/ ` directory.
5759The 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.:
105107
106108 set SPHINXOPTS = & set O = -j4 -Dplot_formats=png:100 & make html
107109
108- Showing locally built docs
109- --------------------------
110+ Show locally built docs
111+ -----------------------
110112
111113The built docs are available in the folder :file: `build/html `. A shortcut
112114for opening them in your default browser is:
@@ -117,8 +119,8 @@ for opening them in your default browser is:
117119
118120 .. _writing-rest-pages :
119121
120- Writing ReST pages
121- ==================
122+ Write ReST pages
123+ ================
122124
123125Most documentation is either in the docstrings of individual
124126classes and methods, in explicit ``.rst `` files, or in examples and tutorials.
@@ -189,8 +191,8 @@ nor the ````literal```` role:
189191
190192 .. _internal-section-refs :
191193
192- Referring to other documents and sections
193- -----------------------------------------
194+ Refer to other documents and sections
195+ -------------------------------------
194196
195197Sphinx _ allows internal references _ between documents.
196198
@@ -254,8 +256,8 @@ hyphens to separate words.
254256
255257.. _referring-to-other-code :
256258
257- Referring to other code
258- -----------------------
259+ Refer to other code
260+ -------------------
259261
260262To link to other methods, classes, or modules in Matplotlib you can use
261263back ticks, for example:
@@ -313,8 +315,8 @@ commands::
313315
314316.. _rst-figures-and-includes :
315317
316- Including figures and files
317- ---------------------------
318+ Include figures and files
319+ -------------------------
318320
319321Image files can directly included in pages with the ``image:: `` directive.
320322e.g., :file: `tutorials/intermediate/constrainedlayout_guide.py ` displays
@@ -353,8 +355,8 @@ expression in the Matplotlib figure. In these cases, you can use the
353355
354356.. _writing-docstrings :
355357
356- Writing docstrings
357- ==================
358+ Write docstrings
359+ ================
358360
359361Most of the API documentation is written in docstrings. These are comment
360362blocks in source code that explain how the code works.
@@ -516,8 +518,8 @@ Non-numeric homogeneous sequences are described as lists, e.g.::
516518 list of str
517519 list of `.Artist`
518520
519- Referencing types
520- ~~~~~~~~~~~~~~~~~
521+ Reference types
522+ ~~~~~~~~~~~~~~~
521523Generally, the rules from referring-to-other-code _ apply. More specifically:
522524
523525Use full references ```~matplotlib.colors.Normalize` `` with an
@@ -584,8 +586,8 @@ also`` sections. No need to use backticks there::
584586 vlines : vertical lines
585587 axhline : horizontal line across the Axes
586588
587- Wrapping parameter lists
588- ~~~~~~~~~~~~~~~~~~~~~~~~
589+ Wrap parameter lists
590+ ~~~~~~~~~~~~~~~~~~~~
589591Long parameter lists should be wrapped using a ``\ `` for continuation and
590592starting on the new line without any indent (no indent because pydoc will
591593parse 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
744746``__init__.__doc__ ``.
745747
746748
747- Inheriting docstrings
748- ---------------------
749+ Inherit docstrings
750+ ------------------
749751
750752If a subclass overrides a method but does not change the semantics, we can
751753reuse the parent docstring for the method of the child class. Python does this
@@ -768,8 +770,8 @@ the future::
768770
769771.. _docstring-adding-figures :
770772
771- Adding figures
772- --------------
773+ Add figures
774+ -----------
773775
774776As above (see :ref: `rst-figures-and-includes `), figures in the examples gallery
775777can be referenced with a ``.. plot:: `` directive pointing to the python script
@@ -813,8 +815,8 @@ code will also appear in interactive docstrings.
813815
814816.. _writing-examples-and-tutorials :
815817
816- Writing examples and tutorials
817- ==============================
818+ Write examples and tutorials
819+ ============================
818820
819821Examples and tutorials are Python scripts that are run by `Sphinx Gallery `_.
820822Sphinx 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
841843In the Python files, to exclude an example from having a plot generated, insert
842844"sgskip" somewhere in the filename.
843845
844- Formatting the example
845- ----------------------
846+ Format
847+ ------
846848
847849The format of these files is relatively straightforward. Properly
848850formatted comment blocks are treated as ReST _ text, the code is
@@ -913,8 +915,26 @@ ReST text are delimited by the line ``# %%`` :
913915
914916 In this way text, code, and figures are output in a "notebook" style.
915917
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+ -------------------
918938
919939The showcased Matplotlib functions should be listed in an admonition at the
920940bottom as follows
@@ -942,8 +962,9 @@ Functions that exist in ``pyplot`` as well as in Axes or Figure should mention
942962both references no matter which one is used in the example code. The ``pyplot ``
943963reference should always be the second to mention; see the example above.
944964
945- Order of examples in the gallery
946- --------------------------------
965+
966+ Order examples
967+ --------------
947968
948969The order of the sections of the :ref: `tutorials ` and the :ref: `gallery `, as
949970well as the order of the examples within each section are determined in a
@@ -984,8 +1005,8 @@ manual ``index.rst``.
9841005Miscellaneous
9851006=============
9861007
987- Moving documentation
988- --------------------
1008+ Move documentation
1009+ ------------------
9891010
9901011Sometimes it is desirable to move or consolidate documentation. With no
9911012action this will lead to links either going dead (404) or pointing to old
@@ -1020,8 +1041,8 @@ For clarity, do not use relative links.
10201041
10211042.. _inheritance-diagrams :
10221043
1023- Generating inheritance diagrams
1024- -------------------------------
1044+ Generate inheritance diagrams
1045+ -----------------------------
10251046
10261047Class inheritance diagrams can be generated with the Sphinx
10271048`inheritance-diagram `_ directive.
0 commit comments