diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-03-24 09:32:12 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-03-25 09:22:04 +0100 |
| commit | 51bb4a19269427ad736a7046d5ad9fef5f881508 (patch) | |
| tree | 261d07604e818ce98705ced66fce2a60581dd432 /tools/example_gallery/main.py | |
| parent | 8ee50d9261c773854ad288f3ebfbc7c5b1c6ae40 (diff) | |
Example gallery tool: Add more file types
As a drive-by, streamline the code.
Task-number: PYSIDE-1106
Pick-to: 6.5
Change-Id: If996cb6f813a641fb4dd51cad2e41be3b26dcc07
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@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.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py index 1e9e3040b..359bce003 100644 --- a/tools/example_gallery/main.py +++ b/tools/example_gallery/main.py @@ -22,6 +22,14 @@ from pathlib import Path from textwrap import dedent opt_quiet = False + + +IMAGE_SUFFIXES = (".png", ".jpg", ".jpeg", ".gif", ".svg", ".svgz", ".webp") + + +IGNORED_SUFFIXES = IMAGE_SUFFIXES + (".pdf", ".pyc") + + suffixes = { ".h": "cpp", ".cpp": "cpp", @@ -32,6 +40,7 @@ suffixes = { ".qrc": "xml", ".ui": "xml", ".xbel": "xml", + ".xml": "xml", } @@ -42,10 +51,8 @@ def ind(x): def get_lexer(path): if path.name == "CMakeLists.txt": return "cmake" - suffix = path.suffix - if suffix in suffixes: - return suffixes[suffix] - return "text" + lexer = suffixes.get(path.suffix) + return lexer if lexer else "text" def add_indent(s, level): @@ -144,7 +151,7 @@ def get_code_tabs(files, project_dir): content += ".. tab-set::\n\n" pfile = Path(project_file) - if pfile.suffix in (".jpg", ".pdf", ".png", ".pyc", ".svg", ".svgz"): + if pfile.suffix in IGNORED_SUFFIXES: continue content += f"{ind(1)}.. tab-item:: {project_file}\n\n" @@ -232,8 +239,7 @@ if __name__ == "__main__": rst_file = f"example_{module_name}_{extra_names}_{example_name}.rst".replace("__", "_") def check_img_ext(i): - EXT = (".png", ".jpg", ".jpeg", ".gif", ".webp") - return i.suffix in EXT + return i.suffix in IMAGE_SUFFIXES # Check for a 'doc' directory inside the example has_doc = False |
