@@ -59,7 +59,9 @@ Building the docs
59
59
-----------------
60
60
61
61
The documentation sources are found in the :file: `doc/ ` directory in the trunk.
62
- To build the documentation in html format, cd into :file: `doc/ ` and run:
62
+ The configuration file for Sphinx is :file: `doc/conf.py `. It controls which
63
+ directories Sphinx parses, how the docs are built, and how the extensions are
64
+ used. To build the documentation in html format, cd into :file: `doc/ ` and run:
63
65
64
66
.. code-block :: sh
65
67
@@ -137,12 +139,12 @@ Documents can be linked with the `:doc:` directive::
137
139
138
140
.. code-block :: rst
139
141
140
- :doc:`/faq/installing_faq`
142
+ :doc:`/faq/installing_faq`
141
143
142
144
will link to :doc: `/faq/installing_faq `.
143
145
144
146
Sections can also be given reference names. For instance from the
145
- :doc: `/faq/installing_faq `:
147
+ :doc: `/faq/installing_faq ` link :
146
148
147
149
.. code-block :: rst
148
150
@@ -151,7 +153,7 @@ Sections can also be given reference names. For instance from the
151
153
How to completely remove Matplotlib
152
154
===================================
153
155
154
- Occasionally, problems with Matplotlib can be solved with a clean
156
+ Occasionally, problems with Matplotlib can be solved with a clean...
155
157
156
158
and refer to it using the standard reference syntax:
157
159
@@ -224,30 +226,33 @@ a list of all objects that can be referenced (in this case for Numpy)::
224
226
225
227
python -m sphinx.ext.intersphinx 'https://docs.scipy.org/doc/numpy/objects.inv'
226
228
227
- .. _ referring-to-mpl-docs :
229
+ .. _rst-figures-and-includes
228
230
229
- Referring to data files
230
- -----------------------
231
+ Including figures and files
232
+ ---------------------------
231
233
232
234
In the documentation, you may want to include to a data file in the Matplotlib
233
235
sources, e.g., a license file or an image file from :file: `mpl-data `,
234
236
refer to it via a relative path from the document where the rst
235
- file resides, e.g.,
236
- in :file: `users/navigation_toolbar.rst `, you can refer to the image icons with::
237
+ file resides,
238
+
239
+ Image files can directly included in pages with the ``image:: `` directive.
240
+ e.g., :file: `users/navigation_toolbar.rst ` displays the toolbar icons
241
+ with a call to a static image::
237
242
238
- .. image:: ../../lib/matplotlib/mpl-data/images/subplots .png
243
+ .. image:: ../_static/toolbar .png
239
244
240
- In the :file: `users ` subdirectory, if you want to refer to a file in the
241
- :file: `mpl-data ` directory, you can use the symlink directory. For example,
242
- from :file: `customizing.rst `::
245
+ as rendered on the page: :ref: `navigation-toolbar `.
243
246
244
- .. literalinclude:: ../../lib/matplotlib/mpl-data/matplotlibrc
247
+ Files can be included verbatim. For instance the ``matplotlibrc `` file
248
+ is important for customizing Matplotlib, and is included verbatim in the
249
+ tutorial in :file: `/tutorials/introductory/customizing.py `::
245
250
246
- One exception to this is when referring to the examples directory. Relative
247
- paths are extremely confusing in the sphinx plot extensions, so it is easier
248
- to simply include a symlink to the files at the top doc level directory.
249
- This way, API documents like :meth: ` matplotlib.pyplot.plot ` can refer to the
250
- examples in a known location.
251
+ .. literalinclude:: ../../_static/matplotlibrc
252
+
253
+ This is rendered as ` /tutorials/introductory/customizing.py ` (see the
254
+ bottom of the page). (Note that this is in a tutorial; See
255
+ :ref: ` writing- examples-and-tutorials ` below)
251
256
252
257
In the top level :file: `doc ` directory we have symlinks pointing to the
253
258
Matplotlib :file: `examples `:
@@ -263,37 +268,9 @@ So we can include plots from the examples dir using the symlink:
263
268
264
269
.. plot:: mpl_examples/pylab_examples/simple_plot.py
265
270
266
-
267
- `include ` statements
268
- --------------------
269
-
270
- Additional files can be added to the various guides by including their base
271
- file name (the .rst extension is not necessary) in the table of contents.
272
- It is also possible to include other documents through the use of an include
273
- statement, such as::
274
-
275
- .. include:: ../../TODO
276
-
277
- The configuration file for Sphinx is :file: `doc/conf.py `. It controls which
278
- directories Sphinx parses, how the docs are built, and how the extensions are
279
- used.
280
-
281
- .. _rest-adding-figures :
282
-
283
- Adding figures
284
- --------------
285
-
286
- Figures in the example gallery can be referenced by te
287
-
288
- There are two options for where to put the code that generates a figure. If
289
- you want to include a plot in the examples gallery, the code should be added to
290
- the :file: `examples ` directory. Plots from
291
- the :file: `examples ` directory can then be referenced through the symlink
292
- ``mpl_examples `` in the ``doc `` directory, e.g.:
293
-
294
- .. code-block :: rst
295
-
296
- .. plot:: mpl_examples/lines_bars_and_markers/fill.py
271
+ Note that the python script that generates the plot is referred to, rather
272
+ than any plot that is created. `Sphinx Gallery `_ will provide the incorrect
273
+ reference when the documentation is built.
297
274
298
275
299
276
.. _writing-docstrings :
@@ -390,6 +367,7 @@ to keep in mind:
390
367
['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \
391
368
'polar' | 'rectilinear'], optional
392
369
The projection type of the axes.
370
+ """
393
371
394
372
Alternatively, you can describe the valid parameter values in a dedicated
395
373
section of the docstring.
@@ -406,23 +384,6 @@ to keep in mind:
406
384
lines : `~matplotlib.collections.LineCollection`
407
385
408
386
409
- Linking to other code
410
- ---------------------
411
- To link to other methods, classes, or modules in Matplotlib you can encase
412
- the name to refer to in back ticks, for example:
413
-
414
- .. code-block:: python
415
-
416
- `~matplotlib.collections.LineCollection`
417
-
418
- It is also possible to add links to code in Python, Numpy, Scipy, or Pandas.
419
- Sometimes it is tricky to get external Sphinx linking to work; to check that
420
- a something exists to link to the following shell command outputs a list of all
421
- objects that can be referenced (in this case for Numpy)::
422
-
423
- python -m sphinx.ext.intersphinx 'https://docs.scipy.org/doc/numpy/objects.inv'
424
-
425
-
426
387
Function arguments
427
388
------------------
428
389
Function arguments and keywords within docstrings should be referred to using
0 commit comments