diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-10 14:46:44 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-16 19:46:40 +0200 |
commit | 08fe1b6cdc32505321a47cf1f9b4d748d2d09953 (patch) | |
tree | 4c5a365f449c96cd4a0a2e7bf681f4e410065a5c /tools/update-dbus-docs.py | |
parent | Add updater for dbus introspection in man pages (diff) | |
download | systemd-08fe1b6cdc32505321a47cf1f9b4d748d2d09953.tar.xz systemd-08fe1b6cdc32505321a47cf1f9b4d748d2d09953.zip |
update-dbus-docs: add support for settings printing just one selected interface
So far the units there were being documented had only one custom interface.
But for the pid1 case, something more flexibile is needed. So let's add
an annotation in the page what we want to print, and filter in the generator.
Diffstat (limited to 'tools/update-dbus-docs.py')
-rwxr-xr-x | tools/update-dbus-docs.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py index 2f69b50b89..41612947ab 100755 --- a/tools/update-dbus-docs.py +++ b/tools/update-dbus-docs.py @@ -99,12 +99,15 @@ def print_property(declarations, elem, *, prefix, file): access = ACCESS_MAP.get(access, access) print(f'''{prefix}{access} {type} {name} = {value_ellipsis(type)};''', file=file) -def print_interface(iface, *, prefix, file, print_boring, declarations): +def print_interface(iface, *, prefix, file, print_boring, only_interface, declarations): name = iface.get('name') - is_boring = name in BORING_INTERFACES + is_boring = (name in BORING_INTERFACES or + only_interface is not None and name != only_interface) + if is_boring and print_boring: print(f'''{prefix}interface {name} {{ ... }};''', file=file) + elif not is_boring and not print_boring: print(f'''{prefix}interface {name} {{''', file=file) prefix2 = prefix + ' ' @@ -157,7 +160,7 @@ def check_documented(document, declarations): return missing -def xml_to_text(destination, xml): +def xml_to_text(destination, xml, *, only_interface=None): file = io.StringIO() declarations = collections.defaultdict(list) @@ -168,6 +171,7 @@ def xml_to_text(destination, xml): for iface in xml.findall('./interface'): print_interface(iface, prefix=' ', file=file, print_boring=print_boring, + only_interface=only_interface, declarations=declarations) print(f'''}};''', file=file) @@ -180,6 +184,8 @@ def subst_output(document, programlisting): except NoCommand: return + only_interface = programlisting.get('interface', None) + argv = shlex.split(cmd) argv += ['--xml'] print(f'COMMAND: {shlex.join(argv)}') @@ -195,7 +201,7 @@ def subst_output(document, programlisting): xml = etree.fromstring(out, parser=PARSER) - new_text, declarations = xml_to_text(object_path, xml) + new_text, declarations = xml_to_text(object_path, xml, only_interface=only_interface) programlisting.text = '\n'.join(prefix_lines) + '\n' + new_text + footer |