aboutsummaryrefslogtreecommitdiffstats
path: root/tools/example_gallery/main.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-04 10:29:19 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-04 17:04:37 +0200
commit7ed292b19ee6a4cd59b8c8f644abba56a8f13f39 (patch)
tree1328dcbb72303e3978cd58d6350b1fd70fd3684f /tools/example_gallery/main.py
parentf566b2fcfa64988ccd3907de701682c4f44b340c (diff)
example_gallery: Ensure tutorials are grouped together
Sort the example lists by rst file key. As a drive-by, also shorten dir names with "advanced". Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: I61a4759b5ed41a3f99e7a2a9955c47f8b3fb3ed2 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Diffstat (limited to 'tools/example_gallery/main.py')
-rw-r--r--tools/example_gallery/main.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index 90b1168a6..23892c57a 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -114,6 +114,8 @@ def get_module_gallery(examples):
# Fix long names
if name.startswith("chapter"):
name = name.replace("chapter", "c")
+ elif name.startswith("advanced"):
+ name = name.replace("advanced", "a")
gallery += f"{ind(1)}.. grid-item-card:: {name}\n"
gallery += f"{ind(2)}:class-item: cover-img\n"
@@ -350,6 +352,13 @@ def write_example(pyproject_file):
return (module_name, result)
+def sort_examples(example):
+ result = {}
+ for module in example.keys():
+ result[module] = sorted(example.get(module), key=lambda e: e.get("rst"))
+ return result
+
+
if __name__ == "__main__":
# Only examples with a '.pyproject' file will be listed.
DIR = Path(__file__).parent
@@ -386,6 +395,8 @@ if __name__ == "__main__":
examples[module_name] = []
examples[module_name].append(data)
+ examples = sort_examples(examples)
+
# We generate a 'toctree' at the end of the file, to include the new
# 'example' rst files, so we get no warnings, and also that users looking
# for them will be able to, since they are indexed.