Skip to content

Commit 0c12607

Browse files
authored
Merge pull request matplotlib#31010 from story645/misc-doc
DOC: update and slightly reorg docs docs
2 parents ec3e68d + 60ab916 commit 0c12607

1 file changed

Lines changed: 83 additions & 93 deletions

File tree

doc/devel/document.rst

Lines changed: 83 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,53 @@
66
Write documentation
77
===================
88

9-
Getting started
10-
===============
11-
12-
General file structure
13-
----------------------
14-
15-
All documentation is built from the :file:`doc/`. The :file:`doc/`
16-
directory contains configuration files for Sphinx and reStructuredText
17-
(ReST_; ``.rst``) files that are rendered to documentation pages.
18-
19-
Documentation is created in three ways. First, API documentation
20-
(:file:`doc/api`) is created by Sphinx_ from
21-
the docstrings of the classes in the Matplotlib library. Except for
22-
:file:`doc/api/api_changes/`, ``.rst`` files in :file:`doc/api` are created
23-
when the documentation is built. See :ref:`writing-docstrings` below.
24-
25-
Second, our example pages, tutorials, and some of the narrative documentation
26-
are created by `Sphinx Gallery`_. Sphinx Gallery converts example Python files
27-
to ``*.rst`` files with the result of Matplotlib plot calls as embedded images.
28-
See :ref:`writing-examples-and-tutorials` below.
29-
30-
Third, Matplotlib has narrative docs written in ReST_ in subdirectories of
31-
:file:`doc/users/`. If you would like to add new documentation that is suited
32-
to an ``.rst`` file rather than a gallery or tutorial example, choose an
33-
appropriate subdirectory to put it in, and add the file to the table of
34-
contents of :file:`index.rst` of the subdirectory. See
35-
:ref:`writing-rest-pages` below.
9+
All documentation is built from the :file:`doc/` folder, but (as explained in this guide)
10+
some of these files are generated from inline docstrings or sphinx gallery files.
3611

3712
.. note::
3813

3914
Don't directly edit the ``.rst`` files in :file:`doc/plot_types`,
40-
:file:`doc/gallery`, :file:`doc/tutorials`, and :file:`doc/api`
41-
(excepting :file:`doc/api/api_changes/`). Sphinx_ regenerates
15+
:file:`doc/gallery`, :file:`doc/tutorials`, :file:`doc/users/explain` and
16+
:file:`doc/api` (except :file:`doc/api/api_changes/`). Sphinx_ regenerates
4217
files in these directories when building documentation.
4318

44-
Set up the build
45-
----------------
46-
47-
The documentation for Matplotlib is generated from reStructuredText (ReST_)
48-
using the Sphinx_ documentation generation tool.
19+
Overview
20+
========
21+
Documentation is created in three ways. First, API documentation (:file:`doc/api`) is
22+
created by Sphinx_ from the docstrings of the classes in the Matplotlib library. Except
23+
for :file:`doc/api/api_changes/`, ``.rst`` files in :file:`doc/api` are created
24+
when the documentation is built. See :ref:`writing-docstrings`.
25+
26+
Second, our example pages, tutorials, and some of the user guide are created by
27+
`Sphinx Gallery`_. Sphinx Gallery converts Python files in :file:`galleries` to
28+
``*.rst`` files that contain the results of Matplotlib plot calls as embedded images.
29+
See :ref:`writing-examples-and-tutorials`.
30+
31+
Third, Matplotlib has informative documentation written in ReST in subdirectories of
32+
:file:`doc`. General and historical information about the project is in :file:`doc/project`,
33+
the installation guide is in :file:`doc/install`, and release notes are managed in
34+
:file:`doc/release`. Maintenance documentation is in :file:`doc\devel` and the website
35+
always redirects to the latest version of these documents. We also maintain a list of
36+
external resources in :file:`doc/users/resources/index.rst`. To improve these documents
37+
or add resources, see :ref:`writing-rest-pages`.
38+
39+
Theme
40+
-----
4941

50-
To build the documentation you will need to
51-
:ref:`set up Matplotlib for development <installing_for_devs>`. Note in
52-
particular the :ref:`additional dependencies <doc-dependencies>` required to
53-
build the documentation.
42+
Matplotlib has a few subprojects that share the same navbar and style, so these
43+
are centralized as a sphinx theme at
44+
`mpl_sphinx_theme <https://github.com/matplotlib/mpl-sphinx-theme>`_. Changes to the
45+
style or top bar should be made there to propagate across all subprojects.
5446

5547
.. _build_docs:
5648

5749
Build the docs
58-
--------------
50+
==============
51+
The documentation for Matplotlib is generated from reStructuredText (ReST_)
52+
using the Sphinx_ documentation generation tool. To build the documentation you will
53+
need to :ref:`set up Matplotlib for development <installing_for_devs>`. Note in
54+
particular the :ref:`additional dependencies <doc-dependencies>` required to
55+
build the documentation.
5956

6057
The documentation sources are found in the :file:`doc/` directory.
6158
The configuration file for Sphinx is :file:`doc/conf.py`. It controls which
@@ -71,6 +68,9 @@ used. To build the documentation in html format, cd into :file:`doc/` and run:
7168
Since the documentation is very large, the first build may take 10-20 minutes,
7269
depending on your machine. Subsequent builds will be faster.
7370

71+
Build options
72+
-------------
73+
7474
Other useful invocations include
7575

7676
.. code-block:: sh
@@ -124,6 +124,7 @@ for opening them in your default browser is:
124124
125125
make show
126126
127+
127128
.. _writing-rest-pages:
128129

129130
Write ReST pages
@@ -215,6 +216,18 @@ nor the ````literal```` role:
215216
Do not describe ``argument`` like this.
216217
217218
219+
Write mathematical expressions
220+
------------------------------
221+
222+
In most cases, you will likely want to use one of `Sphinx's builtin Math
223+
extensions <https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__.
224+
In rare cases we want the rendering of the mathematical text in the
225+
documentation html to exactly match with the rendering of the mathematical
226+
expression in the Matplotlib figure. In these cases, you can use the
227+
`matplotlib.sphinxext.mathmpl` Sphinx extension (See also the
228+
:doc:`../users/explain/text/mathtext` tutorial.)
229+
230+
218231
.. _internal-section-refs:
219232

220233
Refer to other documents and sections
@@ -386,16 +399,38 @@ Note that the python script that generates the plot is referred to, rather than
386399
any plot that is created. Sphinx-gallery will provide the correct reference
387400
when the documentation is built.
388401

389-
Tools for writing mathematical expressions
390-
------------------------------------------
402+
Move documentation
403+
------------------
404+
Sometimes it is desirable to move or consolidate documentation. With no
405+
action this will lead to links either going dead (404) or pointing to old
406+
versions of the documentation. Instead, replace the old page
407+
with an html refresh that immediately redirects the viewer to the new
408+
page. So, for example we move ``/doc/topic/old_info.rst`` to
409+
``/doc/topic/new_info.rst``. We remove ``/doc/topic/old_info.rst`` and
410+
in ``/doc/topic/new_info.rst`` we insert a ``redirect-from`` directive that
411+
tells sphinx to still make the old file with the html refresh/redirect in it
412+
(probably near the top of the file to make it noticeable)
413+
414+
.. code-block:: rst
415+
416+
.. redirect-from:: /topic/old_info
417+
418+
In the built docs this will yield an html file
419+
``/build/html/topic/old_info.html`` that has a refresh to ``new_info.html``.
420+
If the two files are in different subdirectories:
421+
422+
.. code-block:: rst
423+
424+
.. redirect-from:: /old_topic/old_info2
425+
426+
will yield an html file ``/build/html/old_topic/old_info2.html`` that has a
427+
(relative) refresh to ``../topic/new_info.html``.
428+
429+
Use the full path for this directive, relative to the doc root at
430+
``https://matplotlib.org/stable/``. So ``/old_topic/old_info2`` would be
431+
found by users at ``http://matplotlib.org/stable/old_topic/old_info2``.
432+
For clarity, do not use relative links.
391433

392-
In most cases, you will likely want to use one of `Sphinx's builtin Math
393-
extensions <https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__.
394-
In rare cases we want the rendering of the mathematical text in the
395-
documentation html to exactly match with the rendering of the mathematical
396-
expression in the Matplotlib figure. In these cases, you can use the
397-
`matplotlib.sphinxext.mathmpl` Sphinx extension (See also the
398-
:doc:`../users/explain/text/mathtext` tutorial.)
399434

400435
.. _writing-docstrings:
401436

@@ -1164,51 +1199,6 @@ Format
11641199
:code: The code should be about 5-10 lines with minimal customization. Plots in
11651200
this gallery use the ``_mpl-gallery`` stylesheet for a uniform aesthetic.
11661201

1167-
Miscellaneous
1168-
=============
1169-
1170-
Move documentation
1171-
------------------
1172-
1173-
Sometimes it is desirable to move or consolidate documentation. With no
1174-
action this will lead to links either going dead (404) or pointing to old
1175-
versions of the documentation. Preferable is to replace the old page
1176-
with an html refresh that immediately redirects the viewer to the new
1177-
page. So, for example we move ``/doc/topic/old_info.rst`` to
1178-
``/doc/topic/new_info.rst``. We remove ``/doc/topic/old_info.rst`` and
1179-
in ``/doc/topic/new_info.rst`` we insert a ``redirect-from`` directive that
1180-
tells sphinx to still make the old file with the html refresh/redirect in it
1181-
(probably near the top of the file to make it noticeable)
1182-
1183-
.. code-block:: rst
1184-
1185-
.. redirect-from:: /topic/old_info
1186-
1187-
In the built docs this will yield an html file
1188-
``/build/html/topic/old_info.html`` that has a refresh to ``new_info.html``.
1189-
If the two files are in different subdirectories:
1190-
1191-
.. code-block:: rst
1192-
1193-
.. redirect-from:: /old_topic/old_info2
1194-
1195-
will yield an html file ``/build/html/old_topic/old_info2.html`` that has a
1196-
(relative) refresh to ``../topic/new_info.html``.
1197-
1198-
Use the full path for this directive, relative to the doc root at
1199-
``https://matplotlib.org/stable/``. So ``/old_topic/old_info2`` would be
1200-
found by users at ``http://matplotlib.org/stable/old_topic/old_info2``.
1201-
For clarity, do not use relative links.
1202-
1203-
Navbar and style
1204-
----------------
1205-
1206-
Matplotlib has a few subprojects that share the same navbar and style, so these
1207-
are centralized as a sphinx theme at
1208-
`mpl_sphinx_theme <https://github.com/matplotlib/mpl-sphinx-theme>`_. Changes to the
1209-
style or topbar should be made there to propagate across all subprojects.
1210-
1211-
12121202
Analytics
12131203
==========
12141204

0 commit comments

Comments
 (0)