aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-10 13:22:25 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-10 18:39:30 +0100
commit88e5e9e0399d58b67028ea3082d3b3f5f7429823 (patch)
tree8aa485d5ec0ffb8205dfcc9f62f3652641999ecf
parent729a09a6d6016381d5ab065fe07f4330121fda55 (diff)
Silence the example_gallery tool
Add a --quiet option and use that for quiet builds. Task-number: PYSIDE-1490 Change-Id: I6b8a3fa159acb85dee5fbc064991a09a9fa6ceda Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 9f8fc934818c3ae7473fe6258056bc7c7bf9f718)
-rw-r--r--sources/pyside6/doc/CMakeLists.txt6
-rw-r--r--tools/example_gallery/main.py21
2 files changed, 22 insertions, 5 deletions
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt
index cbec282ab..bfbfb2b8e 100644
--- a/sources/pyside6/doc/CMakeLists.txt
+++ b/sources/pyside6/doc/CMakeLists.txt
@@ -25,8 +25,12 @@ endif()
# Generate example gallery
message(STATUS "Generating example gallery")
+set (EXAMPLE_TOOL_OPTIONS '')
+if (QUIET_BUILD)
+ set (EXAMPLE_TOOL_OPTIONS '-q')
+endif()
set(EXAMPLE_TOOL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../tools/example_gallery/main.py")
-execute_process(COMMAND ${PYTHON_EXECUTABLE} ${EXAMPLE_TOOL_DIR}
+execute_process(COMMAND ${PYTHON_EXECUTABLE} ${EXAMPLE_TOOL_DIR} ${EXAMPLE_TOOL_OPTIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(SHIBOKEN_INTERSPHINX_FILE "${ROOT}/pyside6/shiboken6/objects.inv")
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index bdb983014..afacab628 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -38,7 +38,7 @@
###############
-"""
+DESCRIPTION = """
This tool reads all the examples from the main repository that have a
'.pyproject' file, and generates a special table/gallery in the documentation
page.
@@ -48,12 +48,16 @@ For the usage, simply run:
since there is no special requirements.
"""
+from argparse import ArgumentParser, RawTextHelpFormatter
import json
import math
from pathlib import Path
from textwrap import dedent
+opt_quiet = False
+
+
def ind(x):
return " " * 4 * x
@@ -136,6 +140,12 @@ if __name__ == "__main__":
columns = 5
gallery = ""
+ parser = ArgumentParser(description=DESCRIPTION,
+ formatter_class=RawTextHelpFormatter)
+ parser.add_argument('--quiet', '-q', action='store_true',
+ help='Quiet')
+ options = parser.parse_args()
+ opt_quiet = options.quiet
# This main loop will be in charge of:
# * Getting all the .pyproject files,
@@ -193,9 +203,11 @@ if __name__ == "__main__":
content_f += add_indent(_content, 1)
content_f += "\n\n"
out_f.write(content_f)
- print(f"Written: {EXAMPLES_DOC}/{rst_file}")
+ if not opt_quiet:
+ print(f"Written: {EXAMPLES_DOC}/{rst_file}")
else:
- print("Empty '.pyproject' file, skipping")
+ if not opt_quiet:
+ print("Empty '.pyproject' file, skipping")
base_content = dedent("""\
..
@@ -253,4 +265,5 @@ if __name__ == "__main__":
for i in index_files:
f.write(f" {i}\n")
- print(f"Written index: {EXAMPLES_DOC}/index.rst")
+ if not opt_quiet:
+ print(f"Written index: {EXAMPLES_DOC}/index.rst")