diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-05-04 10:29:19 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-05-04 18:03:41 +0000 |
commit | 14bcdfe09bd5a94816af69f3f91797d3069e45e3 (patch) | |
tree | 63dfeaa22076734185be238d53245392ecbecd71 | |
parent | da04a95d8f7ed83dd9877b44edc41ddf34f77f41 (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".
Task-number: PYSIDE-1106
Change-Id: I61a4759b5ed41a3f99e7a2a9955c47f8b3fb3ed2
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
(cherry picked from commit 7ed292b19ee6a4cd59b8c8f644abba56a8f13f39)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tools/example_gallery/main.py | 11 |
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. |