@@ -20,12 +20,10 @@ the docstrings of the classes in the Matplotlib library. Except for
20
20
:file: `doc/api/api_changes/ `, ``.rst `` files in :file: `doc/api ` are created
21
21
when the documentation is built. See :ref: `writing-docstrings ` below.
22
22
23
- Second, the contents of :file: `doc/plot_types `, :file: `doc/gallery ` and
24
- :file: `doc/tutorials ` are generated by the `Sphinx Gallery `_ from python files
25
- in :file: `galleries/plot_types/ `, :file: `galleries/examples/ ` and
26
- :file: `galleries/tutorials/ `. These sources consist of python scripts that have
27
- ReST _ documentation built into their comments. See
28
- :ref: `writing-examples-and-tutorials ` below.
23
+ Second, our example pages, tutorials, and some of the narrative documentation
24
+ are created by `Sphinx Gallery `_. Sphinx Gallery converts example python files
25
+ to ``*.rst `` files with the result of Matplotlib plot calls as embedded images.
26
+ See :ref: `writing-examples-and-tutorials ` below.
29
27
30
28
Third, Matplotlib has narrative docs written in ReST _ in subdirectories of
31
29
:file: `doc/users/ `. If you would like to add new documentation that is suited
@@ -818,12 +816,28 @@ code will also appear in interactive docstrings.
818
816
Writing examples and tutorials
819
817
==============================
820
818
821
- Examples and tutorials are python scripts that are run by `Sphinx Gallery `_
822
- to create a gallery of images in the :file: `/doc/gallery ` and
823
- :file: `/doc/tutorials ` directories respectively. To exclude an example
819
+ Examples and tutorials are python scripts that are run by `Sphinx Gallery `_.
820
+ Sphinx Gallery finds ``*.py `` files in source directories and runs the files to
821
+ create images and narrative that are embeded in ``*.rst `` files in a build
822
+ location of the :file: `doc/ ` directory. Files in the build location should not
823
+ be directly edited as they will be overwritten by Sphinx gallery. Currently
824
+ Matplotlib has four galleries as follows:
825
+
826
+ =============================== ==========================
827
+ Source location Build location
828
+ =============================== ==========================
829
+ :file: `galleries/plot_types ` :file: `doc/plot_types `
830
+ :file: `galleries/examples ` :file: `doc/gallery `
831
+ :file: `galleries/tutorials ` :file: `doc/tutorials `
832
+ :file: `galleries/users_explain ` :file: `doc/users/explain `
833
+ =============================== ==========================
834
+
835
+ The first three are traditional galleries, :file: `galleries/users_explain ` is a
836
+ mixed gallery where some of the files are raw ``*.rst `` files rather than
837
+ ``*.py `` files; Sphinx Gallery just copies those from the location to the build
838
+ location (see :ref: `raw_restructured_gallery `, below). To exclude an example
824
839
from having an plot generated insert "sgskip" somewhere in the filename.
825
840
826
-
827
841
Formatting the example
828
842
----------------------
829
843
@@ -947,6 +961,23 @@ to name your example consistently, i.e. use the main function or subject
947
961
of the example as first word in the filename; e.g. an image example
948
962
should ideally be named similar to :file: `imshow_mynewexample.py `.
949
963
964
+ .. _raw_restructured_gallery :
965
+
966
+ Raw restructured text files in the gallery
967
+ ------------------------------------------
968
+
969
+ `Sphinx Gallery `_ folders usually consist of a ``README.txt `` and a series of
970
+ python source files that are then translated to an ``index.rst `` file and a
971
+ series of ``example_name.rst `` files in the :file: `doc/ ` subdirectories.
972
+ However, Sphinx Gallery also allows raw ``*.rst `` files to be passed through a
973
+ gallery (see `Manually passing files `_ in the Sphinx Gallery documentation). We
974
+ use this feature in :file: `galleries/users_explain `, where, for instance,
975
+ :file: `galleries/users_explain/colors ` is a regular Sphinx Gallery
976
+ subdirectory, but :file: `galleries/users_explain/artists ` has a mix of
977
+ ``*.rst `` and ``*py `` files. For mixed subdirectories like this, we must add
978
+ any ``*.rst `` files to a ``:toctree: ``, either in the ``README.txt `` or in a
979
+ manual ``index.rst ``.
980
+
950
981
Miscellaneous
951
982
=============
952
983
@@ -1022,3 +1053,4 @@ style or topbar should be made there to propagate across all subprojects.
1022
1053
.. _`Sphinx Gallery` : https://sphinx-gallery.readthedocs.io/en/latest/
1023
1054
.. _references : https://www.sphinx-doc.org/en/stable/usage/restructuredtext/roles.html
1024
1055
.. _`numpydoc docstring guide` : https://numpydoc.readthedocs.io/en/latest/format.html
1056
+ .. _`Manually passing files` : https://sphinx-gallery.github.io/stable/configuration.html#manually-passing-files
0 commit comments