summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-08-27 19:21:21 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-08-27 20:22:40 +0200
commitaf4c7dc26936334f32b40bcd97bc6d8405011f68 (patch)
treec20798719e7430eb18cbf731a8f5de8d4172f248 /tools
parentb7be416f55eda143b0e8f4a8ded8649c92e77d4e (diff)
downloadsystemd-af4c7dc26936334f32b40bcd97bc6d8405011f68.tar.gz
update-dbus-docs: print statistics at the end
Right now: org.freedesktop.LogControl1.xml: 3/3 org.freedesktop.home1.xml: 44/44 org.freedesktop.hostname1.xml: 21/21 org.freedesktop.import1.xml: 17/19 org.freedesktop.locale1.xml: 10/10 org.freedesktop.login1.xml: 172/172 org.freedesktop.machine1.xml: 49/65 org.freedesktop.resolve1.xml: 25/61 org.freedesktop.systemd1.xml: 214/1468 org.freedesktop.timedate1.xml: 12/12 total: 567/1875 :(
Diffstat (limited to 'tools')
-rwxr-xr-xtools/update-dbus-docs.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py
index f95faaaf22..8aa3742f60 100755
--- a/tools/update-dbus-docs.py
+++ b/tools/update-dbus-docs.py
@@ -120,9 +120,11 @@ def document_has_elem_with_text(document, elem, item_repr):
else:
return False
-def check_documented(document, declarations):
+def check_documented(document, declarations, stats):
missing = []
for klass, items in declarations.items():
+ stats['total'] += len(items)
+
for item in items:
if klass == 'method':
elem = 'function'
@@ -141,6 +143,8 @@ def check_documented(document, declarations):
print(f'{klass} {item} is not documented :(')
missing.append((klass, item))
+ stats['missing'] += len(missing)
+
return missing
def xml_to_text(destination, xml, *, only_interface=None):
@@ -165,7 +169,7 @@ def xml_to_text(destination, xml, *, only_interface=None):
return file.getvalue(), declarations, interfaces
-def subst_output(document, programlisting):
+def subst_output(document, programlisting, stats):
executable = programlisting.get('executable', None)
if executable is None:
# Not our thing
@@ -189,7 +193,7 @@ def subst_output(document, programlisting):
programlisting.text = '\n' + new_text + ' '
if declarations:
- missing = check_documented(document, declarations)
+ missing = check_documented(document, declarations, stats)
parent = programlisting.getparent()
# delete old comments
@@ -253,9 +257,11 @@ def process(page):
if xml.tag != 'refentry':
return
+ stats = collections.Counter()
+
pls = xml.findall('.//programlisting')
for pl in pls:
- subst_output(xml, pl)
+ subst_output(xml, pl, stats)
out_text = etree.tostring(xml, encoding='unicode')
# massage format to avoid some lxml whitespace handling idiosyncrasies
@@ -267,6 +273,8 @@ def process(page):
with open(page, 'w') as out:
out.write(out_text)
+ return stats
+
if __name__ == '__main__':
pages = sys.argv[1:]
@@ -279,5 +287,13 @@ if __name__ == '__main__':
if not os.path.exists(f'{build_dir}/systemd'):
exit(f"{build_dir}/systemd doesn't exist. Use --build-dir=.")
- for page in pages:
- process(page)
+ stats = {page.split('/')[-1] : process(page) for page in pages}
+
+ # Let's print all statistics at the end
+ mlen = max(len(page) for page in stats)
+ total = 'total', sum(stats.values(), start=collections.Counter())
+ for page, counts in sorted(stats.items()) + [total]:
+ m = counts['missing']
+ t = counts['total']
+ p = page + ':'
+ print(f'{p:{mlen + 1}} {t - m}/{t}')