Skip to content

Commit f92c8d1

Browse files
committed
update-dbus-docs: automatically add variablelist for introspected items
Add a <variablelist/> tag after every programlisting we auto-generate that will be read by make-directive-index to cross-reference all dbus elements.
1 parent 8906e26 commit f92c8d1

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

tools/make-directive-index.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,38 @@
160160
<variablelist id='filenames' />
161161
</refsect1>
162162
163+
<refsect1>
164+
<title>D-Bus interfaces</title>
165+
166+
<para>Interaces exposed over D-Bus.</para>
167+
168+
<variablelist id='dbus-interface' />
169+
</refsect1>
170+
171+
<refsect1>
172+
<title>D-Bus methods</title>
173+
174+
<para>Methods exposed in the D-Bus interface.</para>
175+
176+
<variablelist id='dbus-method' />
177+
</refsect1>
178+
179+
<refsect1>
180+
<title>D-Bus properties</title>
181+
182+
<para>Properties exposed in the D-Bus interface.</para>
183+
184+
<variablelist id='dbus-property' />
185+
</refsect1>
186+
187+
<refsect1>
188+
<title>D-Bus signals</title>
189+
190+
<para>Signals emitted in the D-Bus interface.</para>
191+
192+
<variablelist id='dbus-signal' />
193+
</refsect1>
194+
163195
<refsect1>
164196
<title>Colophon</title>
165197
<para id='colophon' />

tools/update-dbus-docs.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def xml_to_text(destination, xml, *, only_interface=None):
164164
file = io.StringIO()
165165

166166
declarations = collections.defaultdict(list)
167+
interfaces = []
167168

168169
print(f'''node {destination} {{''', file=file)
169170

@@ -173,10 +174,13 @@ def xml_to_text(destination, xml, *, only_interface=None):
173174
print_boring=print_boring,
174175
only_interface=only_interface,
175176
declarations=declarations)
177+
name = iface.get('name')
178+
if not name in BORING_INTERFACES:
179+
interfaces.append(name)
176180

177181
print(f'''}};''', file=file)
178182

179-
return file.getvalue(), declarations
183+
return file.getvalue(), declarations, interfaces
180184

181185
def subst_output(document, programlisting):
182186
try:
@@ -201,7 +205,7 @@ def subst_output(document, programlisting):
201205

202206
xml = etree.fromstring(out, parser=PARSER)
203207

204-
new_text, declarations = xml_to_text(object_path, xml, only_interface=only_interface)
208+
new_text, declarations, interfaces = xml_to_text(object_path, xml, only_interface=only_interface)
205209

206210
programlisting.text = '\n'.join(prefix_lines) + '\n' + new_text + footer
207211

@@ -211,9 +215,50 @@ def subst_output(document, programlisting):
211215

212216
# delete old comments
213217
for child in parent:
218+
if (child.tag == etree.Comment
219+
and 'Autogenerated' in child.text):
220+
parent.remove(child)
214221
if (child.tag == etree.Comment
215222
and 'not documented' in child.text):
216223
parent.remove(child)
224+
if (child.tag == "variablelist"
225+
and child.attrib.get("generated",False) == "True"):
226+
parent.remove(child)
227+
228+
# insert pointer for systemd-directives generation
229+
the_tail = programlisting.tail #tail is erased by addnext, so save it here.
230+
prev_element = etree.Comment("Autogenerated cross-references for systemd.directives, do not edit")
231+
programlisting.addnext(prev_element)
232+
programlisting.tail = the_tail
233+
234+
for interface in interfaces:
235+
variablelist = etree.Element("variablelist")
236+
variablelist.attrib['class'] = 'dbus-interface'
237+
variablelist.attrib['generated'] = 'True'
238+
variablelist.attrib['extra-ref'] = interface
239+
240+
prev_element.addnext(variablelist)
241+
prev_element.tail = the_tail
242+
prev_element = variablelist
243+
244+
for decl_type,decl_list in declarations.items():
245+
for declaration in decl_list:
246+
variablelist = etree.Element("variablelist")
247+
variablelist.attrib['class'] = 'dbus-'+decl_type
248+
variablelist.attrib['generated'] = 'True'
249+
if decl_type == 'method' :
250+
variablelist.attrib['extra-ref'] = declaration + '()'
251+
else:
252+
variablelist.attrib['extra-ref'] = declaration
253+
254+
prev_element.addnext(variablelist)
255+
prev_element.tail = the_tail
256+
prev_element = variablelist
257+
258+
last_element = etree.Comment("End of Autogenerated section")
259+
prev_element.addnext(last_element)
260+
prev_element.tail = the_tail
261+
last_element.tail = the_tail
217262

218263
# insert comments for undocumented items
219264
for item in reversed(missing):

0 commit comments

Comments
 (0)