summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-04-24 12:09:07 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-05-05 22:41:23 +0200
commitc351d568c3ddf5a10231f9d5e8c9d7059292767c (patch)
treeff42fe8d2ed490d9d43f1b5b508ca149886568f8 /tools
parent5c08257b709fb1c4a50e8cadde1c004ad75d406a (diff)
downloadsystemd-c351d568c3ddf5a10231f9d5e8c9d7059292767c.tar.gz
update-dbus-docs: use executables in build/
Diffstat (limited to 'tools')
-rwxr-xr-xtools/update-dbus-docs.py54
1 files changed, 21 insertions, 33 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py
index 95a22bebfa..f95faaaf22 100755
--- a/tools/update-dbus-docs.py
+++ b/tools/update-dbus-docs.py
@@ -3,10 +3,10 @@
import collections
import sys
+import os
import shlex
import subprocess
import io
-import pprint
from lxml import etree
PARSER = etree.XMLParser(no_network=True,
@@ -19,23 +19,6 @@ PRINT_ERRORS = True
class NoCommand(Exception):
pass
-def find_command(lines):
- acc = []
- for num, line in enumerate(lines):
- # skip empty leading line
- if num == 0 and not line:
- continue
- cont = line.endswith('\\')
- if cont:
- line = line[:-1].rstrip()
- acc.append(line if not acc else line.lstrip())
- if not cont:
- break
- joined = ' '.join(acc)
- if not joined.startswith('$ '):
- raise NoCommand
- return joined[2:], lines[:num+1] + [''], lines[-1]
-
BORING_INTERFACES = [
'org.freedesktop.DBus.Peer',
'org.freedesktop.DBus.Introspectable',
@@ -183,31 +166,27 @@ def xml_to_text(destination, xml, *, only_interface=None):
return file.getvalue(), declarations, interfaces
def subst_output(document, programlisting):
- try:
- cmd, prefix_lines, footer = find_command(programlisting.text.splitlines())
- except NoCommand:
+ executable = programlisting.get('executable', None)
+ if executable is None:
+ # Not our thing
return
+ executable = programlisting.get('executable')
+ node = programlisting.get('node')
+ interface = programlisting.get('interface')
- only_interface = programlisting.get('interface', None)
-
- argv = shlex.split(cmd)
- argv += ['--xml']
+ argv = [f'{build_dir}/{executable}', f'--bus-introspect={interface}']
print(f'COMMAND: {shlex.join(argv)}')
- object_idx = argv.index('--object-path')
- object_path = argv[object_idx + 1]
-
try:
out = subprocess.check_output(argv, text=True)
- except subprocess.CalledProcessError:
- print('command failed, ignoring', file=sys.stderr)
+ except FileNotFoundError:
+ print(f'{executable} not found, ignoring', file=sys.stderr)
return
xml = etree.fromstring(out, parser=PARSER)
- new_text, declarations, interfaces = xml_to_text(object_path, xml, only_interface=only_interface)
-
- programlisting.text = '\n'.join(prefix_lines) + '\n' + new_text + footer
+ new_text, declarations, interfaces = xml_to_text(node, xml, only_interface=interface)
+ programlisting.text = '\n' + new_text + ' '
if declarations:
missing = check_documented(document, declarations)
@@ -291,5 +270,14 @@ def process(page):
if __name__ == '__main__':
pages = sys.argv[1:]
+ if pages[0].startswith('--build-dir='):
+ build_dir = pages[0].partition('=')[2]
+ pages = pages[1:]
+ else:
+ build_dir = 'build'
+
+ 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)