Skip to content

Commit 2bb91bb

Browse files
committed
DOC: add document on how to document guidelines
1 parent 5bcff66 commit 2bb91bb

File tree

1 file changed

+110
-25
lines changed

1 file changed

+110
-25
lines changed

doc/devel/document.rst

Lines changed: 110 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -955,10 +955,10 @@ Example:
955955
.. inheritance-diagram:: matplotlib.patches matplotlib.lines matplotlib.text
956956
:parts: 2
957957

958-
.. _writing-examples-and-tutorials:
958+
.. _create-examples-and-tutorials:
959959

960-
Write examples and tutorials
961-
============================
960+
Create examples and tutorials
961+
=============================
962962

963963
Examples and tutorials are Python scripts that are run by `Sphinx Gallery`_.
964964
Sphinx Gallery finds ``*.py`` files in source directories and runs the files to
@@ -967,25 +967,43 @@ location of the :file:`doc/` directory. Files in the build location should not
967967
be directly edited as they will be overwritten by Sphinx gallery. Currently
968968
Matplotlib has four galleries as follows:
969969

970-
=============================== ==========================
971-
Source location Build location
972-
=============================== ==========================
973-
:file:`galleries/plot_types` :file:`doc/plot_types`
974-
:file:`galleries/examples` :file:`doc/gallery`
975-
:file:`galleries/tutorials` :file:`doc/tutorials`
976-
:file:`galleries/users_explain` :file:`doc/users/explain`
977-
=============================== ==========================
978-
979-
The first three are traditional galleries. The last,
980-
:file:`galleries/users_explain`, is a mixed gallery where some of the files are
981-
raw ``*.rst`` files and some are ``*.py`` files; Sphinx Gallery just copies
982-
these ``*.rst`` files from the source location to the build location (see
983-
:ref:`raw_restructured_gallery`, below).
970+
.. list-table::
971+
:widths: 20 28 22 30
972+
:header-rows: 1
973+
974+
* - Gallery
975+
- Source location
976+
- Build location
977+
- Purpose
978+
* - ``users_explain``
979+
- :file:`galleries/users_explain`
980+
- :file:`doc/users/explain`
981+
- User guide narrative explanations of how to use Matplotlib.
982+
* - ``plot_types``
983+
- :file:`galleries/plot_types`
984+
- :file:`doc/plot_types`
985+
- A curated overview of the plot types Matplotlib provides out of the box.
986+
* - ``examples``
987+
- :file:`galleries/examples`
988+
- :file:`doc/gallery`
989+
- Visual examples that demonstrate features and common (and uncommon) usage patterns.
990+
* - ``tutorials``
991+
- :file:`galleries/tutorials`
992+
- :file:`doc/tutorials`
993+
- Step-by-step guides for learning broader workflows in more depth.
994+
995+
See :ref:`organizing-examples-and-tutorials` for more information about how to
996+
choose what content goes in which gallery.
997+
998+
In terms of how they are created, the first three are traditional Sphinx
999+
galleries. The last, :file:`galleries/users_explain`, is a mixed gallery where
1000+
some of the files are raw ``*.rst`` files and some are ``*.py`` files; Sphinx
1001+
Gallery just copies these ``*.rst`` files from the source location to the build
1002+
location (see :ref:`raw_restructured_gallery`, below).
9841003

9851004
In the Python files, to exclude an example from having a plot generated, insert
9861005
"sgskip" somewhere in the filename.
9871006

988-
9891007
The format of these files is relatively straightforward. Properly
9901008
formatted comment blocks are treated as ReST_ text, the code is
9911009
displayed, and figures are put into the built page. Matplotlib uses the
@@ -1142,8 +1160,53 @@ subdirectory, but :file:`galleries/users_explain/artists` has a mix of
11421160
any ``*.rst`` files to a ``:toctree:``, either in the ``README.txt`` or in a
11431161
manual ``index.rst``.
11441162

1145-
Examples guidelines
1146-
-------------------
1163+
.. _organization-of-examples-and-tutorials:
1164+
1165+
Organization of examples and tutorials
1166+
--------------------------------------
1167+
1168+
Outside of the API reference documentation, the Matplotlib documentation consists of
1169+
a collection of examples and tutorials.
1170+
1171+
Users guide guidelines
1172+
^^^^^^^^^^^^^^^^^^^^^^
1173+
1174+
The user's guide is a collection of pages that explain how to use Matplotlib to
1175+
create visualizations. It should help readers understand the main concepts,
1176+
workflow, and decisions involved in making plots with Matplotlib. A reader
1177+
should have a solid understanding of how to approach common plotting tasks
1178+
after working through the user's guide, but it is not meant to be a
1179+
comprehensive API reference.
1180+
1181+
The user's guide should be organized as a coherent narrative so that pages can
1182+
be read linearly and build on previously introduced concepts. It should
1183+
contain more explanation and instruction than the gallery of examples, while
1184+
still being concise and to the point. Cross-link related documentation
1185+
(e.g. tutorials, gallery examples, and API entries) and tag the page with
1186+
related concepts.
1187+
1188+
The user's guide should be organized into sections that cover related topics.
1189+
For example, a section on "Customizing Plots" might include pages on how to
1190+
change colors, fonts, and line styles. Each page should have a clear title that
1191+
describes the content of the page. The code examples should be minimal and
1192+
focused on the concept being explained. Avoid including extraneous code that
1193+
does not directly contribute to the explanation.
1194+
1195+
The material should stay relatively balanced and move between basic and more
1196+
advanced concepts in as natural a manner as possible. The goal is for a user to
1197+
read the material without having to spend too much effort trying to understand
1198+
the examples. Deep dives into one feature set should usually live elsewhere and
1199+
be linked as further reading when appropriate.
1200+
1201+
.. note::
1202+
1203+
The user's guide contains some older material that was ported over from
1204+
Tutorials, so some of the content may not yet conform to the suggestions
1205+
above.
1206+
1207+
1208+
Examples gallery guidelines
1209+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
11471210

11481211
The gallery of examples contains visual demonstrations of matplotlib features. Gallery
11491212
examples exist so that users can scan through visual examples. Unlike tutorials or user
@@ -1157,7 +1220,7 @@ documentation (e.g. tutorials, user guides and API entries) and tag the example
11571220
related concepts.
11581221

11591222
Format
1160-
^^^^^^
1223+
~~~~~~
11611224

11621225
All :ref:`examples-index` should aim to follow these guidelines:
11631226

@@ -1198,15 +1261,36 @@ makes it easier for the reader to map which parts of code correspond to which pa
11981261
the plot.
11991262

12001263
Figure size
1201-
^^^^^^^^^^^
1264+
~~~~~~~~~~~
12021265
When customizing figure sizes, we aim to avoid downscaling in rendered HTML docs.
12031266
The current width limit (induced by *pydata-sphinx-theme*) is 720px, i.e.
12041267
``figsize=(7.2, ...)``, or 896px if the page does not have subsections and
12051268
thus does not have the "On this page" navigation on the right-hand side.
12061269

1270+
Tutorials guidelines
1271+
^^^^^^^^^^^^^^^^^^^^
12071272

1208-
Plot types guidelines
1209-
---------------------
1273+
Tutorials are step-by-step guides for learning broader workflows in more depth.
1274+
They should contain explanation and instruction, and can be more cross-cutting
1275+
than individual sections of the user's guide and more in-depth than an
1276+
example. Tutorials need not be limited to assuming basic Matplotlib knowledge,
1277+
but should clearly state the assumed level of knowledge and learning goals in
1278+
the introduction.
1279+
1280+
Long-form tutorials should be organized as a coherent narrative, with sections
1281+
that build on one another and contribute to a clear end result. Break the
1282+
material into stages with clear subsections, and make it easy for readers to see
1283+
what each section adds and when to refer to other documentation for deeper
1284+
detail on a specific feature. A table of contents may be helpful for longer
1285+
tutorials.
1286+
1287+
Formatting guidelines are the same as for Examples above. Cross-link
1288+
related documentation (e.g. user guides, gallery examples, and API entries) and
1289+
tag the page with related concepts.
1290+
1291+
1292+
Plot types gallery guidelines
1293+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12101294

12111295
The :ref:`plot_types` gallery provides an overview of the types of visualizations that
12121296
Matplotlib provides out of the box, meaning that there is a high-level API for
@@ -1215,7 +1299,8 @@ because this gallery is heavily curated and tightly scoped to methods on
12151299
`matplotlib.axes.Axes`.
12161300

12171301
Format
1218-
^^^^^^
1302+
~~~~~~
1303+
12191304
:title: Method signature with required arguments, e.g. ``plot(x, y)``
12201305
:description: In one sentence, describe the visualization that the method produces and
12211306
link to the API documentation, e.g. *Draws a bar chart. See ~Axes.bar*.

0 commit comments

Comments
 (0)