1
1
.. _documenting-matplotlib :
2
2
3
- ===========================================
4
- Developer's tips for documenting Matplotlib
5
- ===========================================
3
+ ================================
4
+ Developer's tips for documenting
5
+ ================================
6
6
7
7
Getting started
8
8
===============
@@ -54,7 +54,7 @@ Building the docs
54
54
55
55
The documentation sources are found in the :file: `doc/ ` directory in
56
56
the trunk. To build the documentation in html format, cd into
57
- :file: `doc/ ` and run::
57
+ :file: `doc/ ` and run:
58
58
59
59
.. code-block :: sh
60
60
@@ -72,16 +72,15 @@ The list of comamnds and flags for ``make.py`` can be listed by running
72
72
many warnings at once.
73
73
74
74
75
- Organization of Matplotlib's documentation
76
- ==========================================
75
+ Documentation organization
76
+ ==========================
77
77
78
78
The actual reStructured Text files are kept in :file: `doc/users `,
79
79
:file: `doc/devel `, :file: `doc/api ` and :file: `doc/faq `. The main entry point is
80
80
:file: `doc/index.rst `, which pulls in the :file: `index.rst ` file for the users
81
81
guide, developers guide, api reference, and FAQs. The documentation suite is
82
82
built as a single document in order to make the most effective use of cross
83
- referencing (we want to make navigating the Matplotlib documentation as easy as
84
- possible).
83
+ referencing.
85
84
86
85
Additional files can be added to the various guides by including their base
87
86
file name (the .rst extension is not necessary) in the table of contents.
@@ -95,11 +94,14 @@ statement, such as::
95
94
Formatting
96
95
==========
97
96
98
- All new or edited docstrings should conform to the numpydoc guidelines. These
99
- split the docstring down into a number of sections - see
97
+ Most documentaiton lives in "docstrings". These are comment blocks in the source
98
+ code that explain how the code works. All new or edited docstrings should
99
+ conform to the numpydoc guidelines. These split the docstring into a number
100
+ of sections - see
100
101
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt for more
101
- details and a guide to the way docstrings should be written. A simple example
102
- docstring looks like:
102
+ details and a guide to how docstrings should be formatted.
103
+
104
+ An example docstring looks like:
103
105
104
106
.. code-block :: python
105
107
@@ -142,8 +144,8 @@ working with Sphinx in general.
142
144
143
145
Function arguments
144
146
------------------
145
- Function arguments and keywords should be referred to using the
146
- ``*emphasis* `` role. This will keep Matplotlib's documentation consistent
147
+ Function arguments and keywords within docstrings should be referred to using
148
+ the ``*emphasis* `` role. This will keep Matplotlib's documentation consistent
147
149
with Python's documentation:
148
150
149
151
.. code-block :: rst
@@ -221,26 +223,26 @@ Figures
221
223
Dynamically generated figures
222
224
-----------------------------
223
225
224
- Figures can be automatically generated from scripts and included in
225
- the docs. It is not necessary to explicitly save the figure in the
226
- script, this will be done automatically at build time to ensure that
227
- the code that is included runs and produces the advertised figure.
226
+ Figures can be automatically generated from scripts and included in the docs.
227
+ It is not necessary to explicitly save the figure from the script; this will be
228
+ done automatically when the docs are built to ensure that the code that is
229
+ included runs and produces the advertised figure.
228
230
229
- The path should be relative to the ``doc `` directory. Any plots
230
- specific to the documentation should be added to the ``doc/mpl_examples/pyplots ``
231
- directory and committed to git. Plots from the ``examples `` directory
232
- may be referenced through the symlink ``mpl_examples `` in the ``doc ``
233
- directory, e.g.:
231
+ Plotting code should be added to the :file: `examples ` directory. Plots from
232
+ the :file: `examples ` directory may be referenced through the symlink
233
+ ``mpl_examples `` in the ``doc `` directory, e.g.:
234
234
235
235
.. code-block :: rst
236
236
237
- .. plot:: mpl_examples/pylab_examples/simple_plot .py
237
+ .. plot:: mpl_examples/lines_bars_and_markers/fill .py
238
238
239
239
The ``:scale: `` directive rescales the image to some percentage of the
240
240
original size, though we don't recommend using this in most cases
241
241
since it is probably better to choose the correct figure size and dpi
242
242
in Matplotlib and let it handle the scaling.
243
243
244
+ To include plots in docstrings, see the following guide:
245
+
244
246
Plot directive documentation
245
247
''''''''''''''''''''''''''''
246
248
@@ -250,10 +252,8 @@ Examples
250
252
--------
251
253
252
254
The source of the files in the ``examples `` directory are
253
- automatically included in the HTML docs. An image is generated and
254
- included for all examples in the ``api `` and ``pylab_examples ``
255
- directories. To exclude the example from having an image rendered,
256
- insert the following special comment anywhere in the script:
255
+ automatically included in the HTML docs. To exclude the example from having an
256
+ image rendered, insert the following special comment anywhere in the script:
257
257
258
258
.. code-block :: python
259
259
0 commit comments