Skip to content

Commit 013384c

Browse files
committed
DOC: Improve docs on writing documentation
1 parent fee65f1 commit 013384c

1 file changed

Lines changed: 42 additions & 46 deletions

File tree

doc/devel/document.rst

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ for opening them in your default browser is:
154154
155155
.. _writing-rest-pages:
156156

157-
Write ReST pages
158-
================
157+
reStructuredText pages
158+
======================
159159

160160
Most documentation is either in the docstrings of individual
161161
classes and methods, in explicit ``.rst`` files, or in examples and tutorials.
@@ -243,11 +243,15 @@ nor the ````literal```` role:
243243
Do not describe ``argument`` like this.
244244
245245
246-
Write mathematical expressions
247-
------------------------------
246+
Mathematical expressions
247+
------------------------
248+
Use sphinx's built in math support:
249+
250+
- **Inline math:** Use the ``:math:``
251+
`role <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#math>`__
252+
- **Math blocks:** Use the ``.. math::``
253+
`directive <https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#math>`__
248254

249-
In most cases, you will likely want to use one of `Sphinx's builtin Math
250-
extensions <https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__.
251255
In rare cases we want the rendering of the mathematical text in the
252256
documentation html to exactly match with the rendering of the mathematical
253257
expression in the Matplotlib figure. In these cases, you can use the
@@ -257,8 +261,8 @@ expression in the Matplotlib figure. In these cases, you can use the
257261

258262
.. _internal-section-refs:
259263

260-
Refer to other documents and sections
261-
-------------------------------------
264+
Cross-references
265+
----------------
262266

263267
Sphinx_ supports internal references_:
264268

@@ -277,63 +281,55 @@ Role Links target Representation in rendered HTML
277281
.. |ref-dir| replace:: ``:ref:``
278282
.. _ref-dir: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref
279283

280-
Examples:
284+
Document cross-references ``:doc:``
285+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281286

282-
.. code-block:: rst
287+
To cross-link to another page, use the ``:doc:`` role. We generally prefer
288+
absolute paths, starting with ``/`` as the :file:``doc`` root directory.
283289

284-
See the :doc:`/install/index`
290+
Example:
285291

286-
See the tutorial :ref:`quick_start`
292+
.. code-block:: rst
287293
288-
See the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
294+
See the :doc:`/install/index`
289295
290296
will render as:
291297

292298
See the :doc:`/install/index`
293299

294-
See the tutorial :ref:`quick_start`
300+
Section cross-references ``:ref:``
301+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
295302

296-
See the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
303+
To cross-link a specific section, add a reference label before the section
297304

298-
Sections can also be given reference labels. For instance from the
299-
:doc:`/install/index` link:
300305

301306
.. code-block:: rst
302307
303-
.. _clean-install:
308+
.. _pr-author-guidelines:
304309
305-
How to completely remove Matplotlib
306-
===================================
310+
Summary for pull request authors
311+
================================
307312
308-
Occasionally, problems with Matplotlib can be solved with a clean...
309-
310-
and refer to it using the standard reference syntax:
313+
and then link to with the ``:ref:`` role
311314

312315
.. code-block:: rst
313316
314-
See :ref:`clean-install`
315-
316-
will give the following link: :ref:`clean-install`
317+
See the :ref:`pr-author-guidelines`
317318
318-
To maximize internal consistency in section labeling and references,
319-
use hyphen separated, descriptive labels for section references.
320-
Keep in mind that contents may be reorganized later, so
321-
avoid top level names in references like ``user`` or ``devel``
322-
or ``faq`` unless necessary, because for example the FAQ "what is a
323-
backend?" could later become part of the users guide, so the label:
319+
This with render as:
324320

325-
.. code-block:: rst
321+
See the :ref:`pr-author-guidelines`
326322

327-
.. _what-is-a-backend:
323+
Use hyphen-separated, descriptive names for reference labels.
324+
Do not encode the documentation hierarchy in the label as that may change;
325+
e.g. do not prefix all *User guide* labels with ``user-``.
328326

329-
is better than:
327+
Example:
330328

331-
.. code-block:: rst
329+
.. code-block::
332330
333-
.. _faq-backend:
331+
.. _pr-author-guidelines:
334332
335-
In addition, since underscores are widely used by Sphinx itself, use
336-
hyphens to separate words.
337333
338334
.. _referring-to-other-code:
339335

@@ -461,8 +457,8 @@ For clarity, do not use relative links.
461457

462458
.. _writing-docstrings:
463459

464-
Write API documentation
465-
=======================
460+
API documentation
461+
=================
466462

467463
The API reference documentation describes the library interfaces, e.g. inputs, outputs,
468464
and expected behavior. Most of the API documentation is written in docstrings. These are
@@ -957,8 +953,8 @@ Example:
957953

958954
.. _writing-examples-and-tutorials:
959955

960-
Write examples and tutorials
961-
============================
956+
Examples and tutorials
957+
======================
962958

963959
Examples and tutorials are Python scripts that are run by `Sphinx Gallery`_.
964960
Sphinx Gallery finds ``*.py`` files in source directories and runs the files to
@@ -1226,10 +1222,10 @@ Format
12261222
:code: The code should be about 5-10 lines with minimal customization. Plots in
12271223
this gallery use the ``_mpl-gallery`` stylesheet for a uniform aesthetic.
12281224

1229-
Analytics
1230-
==========
1225+
Website analytics
1226+
=================
12311227

1232-
Documentation page analytics are available at
1228+
Analytics of our hosted documentation https://matplotlib.org is available at
12331229
https://views.scientific-python.org/matplotlib.org.
12341230

12351231

0 commit comments

Comments
 (0)