mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
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 :(
This commit is contained in:
parent
b7be416f55
commit
af4c7dc269
@ -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}')
|
||||
|
Loading…
Reference in New Issue
Block a user