summaryrefslogtreecommitdiff
path: root/tools/docs
diff options
context:
space:
mode:
authorMagnus Hagander2021-08-11 12:44:35 +0000
committerMagnus Hagander2021-08-11 12:46:35 +0000
commit291511b5b1a39d888a61a1f579badf4d42ed9d9a (patch)
tree8abd03662336f2a3bc3633d999e96a1036d12055 /tools/docs
parenta04dfc02d8a56ee3330e6e2f83c52905ef06de3f (diff)
Add verbose mode to docs loading and tweak defaults
Instead of printing every single page loaded, print the start of the process and the statitics by default. The existing --quiet parameter continues to work to make the process completely quiet. Add a new parameter --verbose that makes it run in the old way, printing everything.
Diffstat (limited to 'tools/docs')
-rwxr-xr-xtools/docs/docload.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/docs/docload.py b/tools/docs/docload.py
index 427a9345..5ececcb6 100755
--- a/tools/docs/docload.py
+++ b/tools/docs/docload.py
@@ -21,6 +21,8 @@ BOOTSTRAP_FIGURE_CLASS = r'<div\1class="figure col-xl-8 col-lg-10 col-md-12"'
pagecount = 0
# if set to "True" -- mutes any output from the script. Controlled by an option
quiet = False
+# if set to "True" -- outputs extra much data (row-per-file)
+verbose = False
# regular expression used to search and extract the title on a given piece of
# documentation, for further use in the application
re_titlematch = re.compile(r'<title\s*>([^<]+)</title\s*>', re.IGNORECASE)
@@ -76,8 +78,8 @@ def load_doc_file(filename, f, c):
# in order to ensure they are able to display responsively
contents = re_figure_match.sub(BOOTSTRAP_FIGURE_CLASS, contents)
- # if not in quiet mode, output the (filename, title) pair of the docpage that is being processed
- if not quiet:
+ # in verbose mode, output the (filename, title) pair of the docpage that is being processed
+ if verbose:
print("--- file: %s (%s) ---" % (filename, title))
# run libtidy on the content
@@ -99,7 +101,9 @@ def load_svg_file(filename, f, c):
# Main execution
parser = OptionParser(usage="usage: %prog [options] <version> <tarfile>")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet",
- help="Run quietly")
+ help="Run quietly (no output at all)")
+parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
+ help="Run verbosely")
(options, args) = parser.parse_args()
if len(args) != 2:
@@ -107,6 +111,12 @@ if len(args) != 2:
sys.exit(1)
quiet = options.quiet
+verbose = options.verbose
+
+if verbose and quiet:
+ print("Can't be both verbose and quiet at the same time!")
+ sys.exit(1)
+
ver = sys.argv[1]
tarfilename = sys.argv[2]
@@ -124,6 +134,9 @@ tf = tarfile.open(tarfilename)
connection = psycopg2.connect(config.get('db', 'dsn'))
+if not quiet:
+ print("Starting load of documentation for version %s." % (ver, ))
+
curs = connection.cursor()
# Verify that the version exists, and what we're loading
curs.execute("SELECT current FROM core_version WHERE tree=%(v)s", {'v': ver})
@@ -237,4 +250,4 @@ connection.commit()
connection.close()
if not quiet:
- print("Done (%i pages)." % pagecount)
+ print("Done loading docs version %s (%i pages)." % (ver, pagecount))