Add sphinx gallery tutorials config to conf.py
@@ -15,7 +15,7 @@ from pkg_resources import get_distribution
from sphinx_astropy.conf import *
# Sphinx-gallery config
-from sphinx_gallery.sorting import FileNameSortKey
+from sphinx_gallery.sorting import FileNameSortKey, ExplicitOrder
# Load utils docs functions
from gammapy.utils.docs import gammapy_sphinx_ext_activate, SubstitutionCodeBlock
@@ -26,8 +26,8 @@ def setup(app) :
"""
Add the custom directives to Sphinx.
"""
- app.add_config_value('substitutions', [], 'html')
- app.add_directive('substitution-code-block', SubstitutionCodeBlock)
+ app.add_config_value("substitutions", [], "html")
+ app.add_directive("substitution-code-block", SubstitutionCodeBlock)
conf = ConfigParser()
@@ -97,7 +97,7 @@ rst_epilog += """
"""
# This is added to keep the links to PRs in release notes
-changelog_links_docpattern = ['.*changelog.*', 'whatsnew/.*', 'release-notes/.*']
+changelog_links_docpattern = [".*changelog.*", "whatsnew/.*", "release-notes/.*"]
# -- Project information ------------------------------------------------------
@@ -107,14 +107,14 @@ author = setup_cfg["author"]
copyright = "{}, {}".format(datetime.datetime.now().year, setup_cfg["author"])
version = get_distribution(project).version
-release = 'X.Y.Z'
+release = "X.Y.Z"
switch_version = version
if "dev" in version:
switch_version = "dev"
else:
release = version
-substitutions = [('|release|', release)]
+substitutions = [("|release|", release)]
# -- Options for HTML output ---------------------------------------------------
# A NOTE ON HTML THEMES
@@ -229,10 +229,29 @@ suppress_warnings = ["ref.citation"]
# nitpicky = True
sphinx_gallery_conf = {
- "examples_dirs": ["../examples/models"], # path to your example scripts
+ "examples_dirs": [
+ "../examples/models",
+ "tutorials",
+ ], # path to your example scripts
"gallery_dirs": [
- "user-guide/model-gallery"
+ "user-guide/model-gallery",
+ "tutorials",
], # path to where to save gallery generated output
+ "subsection_order": ExplicitOrder(
+ [
+ "../examples/models/spatial",
+ "../examples/models/spectral",
+ "../examples/models/temporal",
+ "tutorials/starting",
+ "tutorials/data",
+ "tutorials/analysis-1d",
+ "tutorials/analysis-2d",
+ "tutorials/analysis-3d",
+ "tutorials/analysis-time",
+ "tutorials/api",
+ ]
+ ),
+ 'filename_pattern': '\.py',
"within_subsection_order": FileNameSortKey,
"download_all_examples": False,
"capture_repr": (),
