diff --git a/doc/conf.py b/doc/conf.py index 1fec5f632d4e..3b85c6c16bd3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -293,6 +293,7 @@ def autodoc_process_bases(app, name, obj, options, bases): sphinx_gallery_conf = { 'backreferences_dir': Path('api', '_as_gen'), + 'minigallery_sort_order': 'sphinxext.gallery_order.preserve_order', # Compression is a significant effort that we skip for local and CI builds. 'compress_images': ('thumbnails', 'images') if is_release_build else (), 'doc_module': ('matplotlib', 'mpl_toolkits'), diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index 0bc6e58f59fc..95ebf86b5193 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -3,6 +3,7 @@ Paths are relative to the conf.py file. """ +import itertools from sphinx_gallery.sorting import ExplicitOrder # Gallery sections shall be displayed in the following order. @@ -127,3 +128,10 @@ def __call__(self, item): # Provide the above classes for use in conf.py sectionorder = MplExplicitOrder(explicit_order_folders) subsectionorder = MplExplicitSubOrder + +_preserve_count = itertools.count() + + +def preserve_order(item): + """A sorting key to preserve the original order of items in minigalleries.""" + return next(_preserve_count) diff --git a/galleries/tutorials/index.rst b/galleries/tutorials/index.rst index 76c0037dca11..52862a252fcd 100644 --- a/galleries/tutorials/index.rst +++ b/galleries/tutorials/index.rst @@ -9,101 +9,12 @@ For shorter examples, see our :ref:`examples page `. You can also find :ref:`external resources ` and a :ref:`FAQ ` in our :ref:`user guide `. - -.. raw:: html - -
- - -.. raw:: html - -
- -.. only:: html - - .. image:: /tutorials/images/thumb/sphx_glr_pyplot_thumb.png - :alt: Pyplot tutorial - - :ref:`sphx_glr_tutorials_pyplot.py` - -.. raw:: html - -
Pyplot tutorial
-
- - -.. raw:: html - -
- -.. only:: html - - .. image:: /tutorials/images/thumb/sphx_glr_coding_shortcuts_thumb.png - :alt: Coding shortcuts - - :ref:`sphx_glr_tutorials_coding_shortcuts.py` - -.. raw:: html - -
Coding shortcuts
-
- - -.. raw:: html - -
- -.. only:: html - - .. image:: /tutorials/images/thumb/sphx_glr_images_thumb.png - :alt: Image tutorial - - :ref:`sphx_glr_tutorials_images.py` - -.. raw:: html - -
Image tutorial
-
- - -.. raw:: html - -
- -.. only:: html - - .. image:: /tutorials/images/thumb/sphx_glr_lifecycle_thumb.png - :alt: The Lifecycle of a Plot - - :ref:`sphx_glr_tutorials_lifecycle.py` - -.. raw:: html - -
The Lifecycle of a Plot
-
- - -.. raw:: html - -
- -.. only:: html - - .. image:: /tutorials/images/thumb/sphx_glr_artists_thumb.png - :alt: Artist tutorial - - :ref:`sphx_glr_tutorials_artists.py` - -.. raw:: html - -
Artist tutorial
-
- - -.. raw:: html - -
- +.. minigallery:: + ../galleries/tutorials/pyplot.py + ../galleries/tutorials/coding_shortcuts.py + ../galleries/tutorials/images.py + ../galleries/tutorials/lifecycle.py + ../galleries/tutorials/artists.py .. toctree:: :hidden: @@ -127,7 +38,6 @@ a :ref:`FAQ ` in our :ref:`user guide `. :download:`Download all examples in Jupyter notebooks: tutorials_jupyter.zip ` - .. _user_guide_tutorials: User guide tutorials