aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-03-18 17:46:53 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-18 23:02:24 +0000
commitece22eb0ab4d35b4f14ac47c3550a4cc52d05a10 (patch)
tree1d346d3bdc8caa08a4e9b552c350da66f637db5f /tools
parentc9788f47faa25f1f0151092a3cfda166b27b6d2e (diff)
doc: create examples dir if it doesn't exist
For the examples gallery tool Change-Id: Ia77d2d22033ccb35df30fa8ed4c7f78de070dec1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 78ac4372ec5b84bd3ef2deac4c41aeacbcdb56ae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/example_gallery/main.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index a55e0f27b..2970180fe 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -167,7 +167,7 @@ def get_header_title(f_path):
if __name__ == "__main__":
# Only examples with a '.pyproject' file will be listed.
DIR = Path(__file__).parent
- EXAMPLES_DOC = f"{DIR}/../../sources/pyside6/doc/examples"
+ EXAMPLES_DOC = Path(f"{DIR}/../../sources/pyside6/doc/examples")
EXAMPLES_DIR = Path(f"{DIR}/../../examples/")
BASE_URL = "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples"
columns = 5
@@ -184,6 +184,11 @@ if __name__ == "__main__":
# * Read the .pyproject file to output the content of each file
# on the final .rst file for that specific example.
examples = {}
+
+ # Create the 'examples' directory if it doesn't exist
+ if not EXAMPLES_DOC.is_dir():
+ EXAMPLES_DOC.mkdir()
+
for f_path in EXAMPLES_DIR.glob("**/*.pyproject"):
if str(f_path).endswith("examples.pyproject"):
continue
@@ -222,7 +227,7 @@ if __name__ == "__main__":
pyproject = json.load(pyf)
if pyproject:
- rst_file_full = Path(EXAMPLES_DOC) / rst_file
+ rst_file_full = EXAMPLES_DOC / rst_file
with open(rst_file_full, "w") as out_f:
if has_doc:
@@ -239,7 +244,7 @@ if __name__ == "__main__":
if _f == doc_rst or _f.is_dir():
continue
src = _f
- dst = Path(EXAMPLES_DOC) / _f.name
+ dst = EXAMPLES_DOC / _f.name
resource_written = shutil.copy(src, dst)
if not opt_quiet: