aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-03-18 17:46:53 +0100
committerCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-03-18 22:16:40 +0100
commit78ac4372ec5b84bd3ef2deac4c41aeacbcdb56ae (patch)
treeb069ab7f8c5096eaa2534249e9b56ff49dac0265 /tools
parent6629810389d0d546a9306d7a65b4c2c20bd5b9a6 (diff)
doc: create examples dir if it doesn't exist
For the examples gallery tool Pick-to: 6.0 Change-Id: Ia77d2d22033ccb35df30fa8ed4c7f78de070dec1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
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: